Doctrine 2 mysql FIELD function in order by -


i'm trying use mysql field function in order clause in query. i'm assuming doctrine 2 doesn't support field function out of box - true? if so, how can use it? have turn whole query native query? there doctrine 2 extension adds functionality?

jeremy hicks, your extension. didn`t know how connect function doctrine, find answer.

$doctrineconfig = $this->em->getconfiguration(); $doctrineconfig->addcustomstringfunction('field', 'doctrineextensions\query\mysql\field'); 

i need field function order entities select in expression. can use function in select, where, between clause, not in order by.

solution:

$qb             ->select("r, field(r.id, " . implode(", ", $ids) . ") hidden field")             ->from("entities\round", "r")             ->where($qb->expr()->in("r.id", $ids))             ->orderby("field"); 

to avoid adding field alias result row need put hidden keyword. how able order values in in expression in doctrine 2.2.


Comments

Popular posts from this blog

Cursor error with postgresql, pgpool and php -

delphi - ESC/P programming! -

c++ - error: use of deleted function -