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??



56.7k
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']);


85.4k

Use:

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