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

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.8k
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.9k

Use:

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