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

Can't Model::find order by column 'order' (errors)

Hi! when I try to use Model::find with order by column "order" it errors. When ordering by other column works fine.

how can i make it to order by column "order"???

edited Sep '15

order is a reserved word in SQL syntax (duh :P). Please get familiar with the languages you're using, because this has nothing to do with Phalcon.

Try using

Model::find(array('order'=>'Model.order'));

Also, when asking for help on forums, the actual error message is rather important!



11.2k

The bad thing I cant escape that with order :( I've tried this - doesn't work + thought there is some escape letter...

When uisng 'order' or when using 'Model.order'

Syntax error, unexpected EOF#0 [internal function]: Phalcon\Mvc\Model\Query->parse() #1 [internal function]: Phalcon\Mvc\Model\Query->execute() \MoviesController.php(105): Phalcon\Mvc\Model::find(Array) #3 [internal function]: MoviesController->showAction('277') #4 [internal function]: Phalcon\Dispatcher->dispatch()

nevermind I'm going just rename column



85.5k
edited Sep '15

sorry but i cant try it right now

    Model::find(array('order'=>'`order`'));


11.2k
edited Sep '15

this does not work, but nvm I've renamed column



34.6k
Accepted
answer