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.

model query

Dear, I get an error when using query model Deprecated: Function Phalcon\Mvc\Model\Criteria::order() is deprecated in F:\xampp\htdocs\fmv2\app\controllers\DiscussionsController.php on line 83**

$this->view->categoriesLevel1 = Categories::query()
                ->where("type_cat = 1")
                ->andWhere("level = 1")
                ->bind(array())
                ->order("number_posts DESC, name")
                ->execute();

How to fix??



125.4k
Accepted
answer

Simplest would be to just use find()

$this->view->categoriesLevel1 = Categories::find(['type_cat = 1 AND level = 1','order'=>'number_posts DESC, name']);


98.8k

Use:

$this->view->categoriesLevel1 = Categories::query()
                ->where("type_cat = 1")
                ->andWhere("level = 1")
                ->bind(array())
                ->orderBy("number_posts DESC, name")
                ->execute();