本文介绍了Phalcon模型按项目受欢迎程度的顺序(出现的次数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我确定我之前已经做过类似的事情,但是找不到它,谷歌也没有帮助.
I'm sure I have done something like this before, but can't find it and google not being helpful.
如果可能,请使用Phalcon模型,我要从ID最高的表格中选择商品-即按人气排序的10项最受欢迎的商品.是否可以使用Model::find("conditions")
?我必须为此使用PHQL吗?
Using Phalcon model if possible, I want to select the items from a table whose ID appears the most - i.e. 10 most popular items ordered by popularity. Is this possible using Model::find("conditions")
? I do I have to use PHQL for this?
推荐答案
使用model :: find
using model::find
Model::find([
'columns' => 'id,count(id) as counter',
'group' => 'id',
'order' => 'counter DESC'
]);
PHQL:
$this->modelsManager->executeQuery('SELECT count(id) AS counter,id FROM ModelName GROUP BY id ORDER BY counter DESC');
这篇关于Phalcon模型按项目受欢迎程度的顺序(出现的次数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!