I have moved an app from a PHP5 to a PHP7 server. It runs almost smoothly except with a bug in a query builer creation. I have a form in which I take elements from an entity user and wnated to order them. As you can see I do not have a WHERE in my query:
->add('user', 'entity', array(
'class' => 'MyappAppliBundle:User',
'property' => 'name',
'required' => false,
'empty_value' => '',
'empty_data' => null,
'query_builder' => function (EntityRepository $br) {
return $br->createQueryBuilder('qb')
->orderBy('qb.name', 'ASC');
}
However, when I try to open my form, I have the following error message:
[Syntax Error] line 0, col 55: Error: Expected Literal, got 'ORDER'
SELECT qb FROM Myapp\AppliBundle\Entity\User qb WHERE ORDER BY qb.name AS
I do not understand why there is a WHERE added here!
If I remove the createQueryBuilder, the form appears perfectly (except the users are not sorted), otherwise I have the error message.
If someone would have an idea, that would be great!
Thanks a lot
EDIT: I am using symfony2 (version 2.3.9 to be precise!)
EDIT 2: I have moved to symfony2.7 now and have changed a little bit the add:
->add('user', 'entity', array(
'class' => 'MyappAppliBundle:User',
'choice_translation_domain' => true,
'choice_label' => 'name',
'required' => false,
'placeholder' => '',
'empty_data' => null,
'query_builder' => function (EntityRepository $br) {
return $br->createQueryBuilder('qb')
->orderBy('qb.name', 'ASC');
}
))
However I still have the same issue with this WHERE thats seems coming out of nowhere.