您能帮我找出如何使用Kohana -Jelly模块插入聚合功能吗?

即我需要显示以下查询的结果:

SELECT COUNT('total_item') AS tot FROM items WHERE category_id = '1'

非常感谢您的帮助。

谢谢

有帮助吗?

解决方案

也许这样的事情会更好:

$count = Jelly::select('item')->where('category', '=', 1)->count();

这将产生此查询:

SELECT COUNT(*) AS `total` FROM `items` WHERE `category_id` = 1

其他提示

简要查看文档。会像

$cnt = Jelly::select("tot")->select("count('total_item') AS total")
       ->where("category_id","=", 1)
       ->limit(1)
       ->execute();

echo $cnt->total;

希望有帮助!

即时通讯与Kohana 3.1一起使用

$ count = orm :: factory('items') - > select(array('count(“ id”)','total_items')) - > find_all();

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top