Closed samiharju closed 5 years ago
The easiest way around this bug is going to be to simply chain the orderBy
statements.
$h->table('people')->select()
->orderBy(new Expression('func1()'))
->orderBy(new Expression('func2()'), 'desc')
->execute();
select * from `people` order by func1() asc, func2() desc
There is still a problem with the internal data structure of the order statements but I will release a Fix soon at least allowing expressions in the order array.
$h->table('people')->select()
->orderBy([new Expression('rand()'), new Expression('rand()')])
->execute();
select * from `people` order by func1() asc, func2() asc
There is currently no way changing the direction per order statement in the array syntax. So the direction is set for all given order statements in the array.
$h->table('people')->select()
->orderBy([new Expression('func1()'), new Expression('func2()')], 'desc')
->execute();
select * from `people` order by func1() desc, func2() desc
The fix should also allow mixed arrays:
$h->table('people')->select()
->orderBy(['name' => 'asc', new Expression('func()')], 'desc')
->execute();
select * from `people` order by `name` asc, func() desc
Expression
as parameters fororderBy()
orderBy()
and one of them isExpression
The following error occurs:
Illegal offset
type on/clancats/hydrahon/src/Query/Sql/Select.php
at line 284.