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.

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!



4.6k

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



67.7k
edited Sep '15

sorry but i cant try it right now

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


4.6k
edited Sep '15

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