Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EntitiesToPropertyTransformer] Entities result order issue #167

Open
jkgroupe opened this issue Jun 30, 2020 · 0 comments
Open

[EntitiesToPropertyTransformer] Entities result order issue #167

jkgroupe opened this issue Jun 30, 2020 · 0 comments

Comments

@jkgroupe
Copy link

Hi,

I have an issue when I select tags in a specific order, the entities result is reordered by id and not by the specific selection

Values order
[5,2,3,1,4]

Result from transformer
[1,2,3,4,5]

To resolve this issue with beberlei/DoctrineExtensions package

// get multiple entities with one query
$entities = $this->em->createQueryBuilder()
       ->select('entity')
       ->from($this->className, 'entity')
       ->where('entity.' . $this->primaryKey . ' IN (:ids)')
       ->setParameter('ids', $values)
       ->orderBy('FIELD(entity.' . $this->primaryKey . ', :ids)') // Ordering by ids
       ->getQuery()
       ->getResult();

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant