Search code examples
phpsymfonydoctrine-ormdoctrine-odmdoctrine-query

doctrine2 order by array with ids


How I can with doctrine2 order by array with ids ?

I have this query:

$qb = $this->createQueryBuilder('u')
        ->select('u', 'n', 'c')
        ->leftJoin('u.notifications', 'n')
        ->leftJoin('u.channel', 'c')
        ->andWhere('u.id IN (:ids)')
        ->setParameter('ids', $ids);

I want that the result has the same order that array with ids, is possible do it ?

Thanks

SOLUTION:

Use FIELD mysql extension with https://github.com/beberlei/DoctrineExtensions

:)

Thanks


Solution

  • I found the solution, it is possible using FIELD mysql extension with https://github.com/beberlei/DoctrineExtensions

    Thanks

    Marc