We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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!