We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to sort(orderby) when field name 'order' ::find or queryBuilder?

(sorry my poor english) Hi All!

My table fields : id, personName, order.

How to select field order by (fieldname) 'order' ?
Try:

:find(array('order'=>'order')

:find(array('order'=>'[order]')

:find(array('order'=>'order')

queryBuilder()->orderBy('order'),

queryBuilder()->orderBy('[order]'),

queryBuilder()->orderBy('`order')

if colums select: ' , 'order' as sort' and 'order by sort' working, but the response not in model class. many tables have 'order' field, and not possible rename all field. :(

Thank you! Andrew



145.0k
Accepted
answer

[order] is not working ? You know that ou need probably pass how you want to order ? DESC/ASC ?



12.2k

You mean your column is called order?



1.1k

ehh ... [order] is working, but NULL lower with 0,1 or 2... and i not see change... :(

thank you!