Aggregate function in Kohana Jelly ORM
could you help me to find out how to insert aggregate function using Kohana - Jelly module?
I.E. i need to show result of following query :
SELECT COUNT('total_item') AS tot FROM items WHERE categ开发者_StackOverflow社区ory_id = '1'
really appreciate your help.
thanks
from briefly looking at the documentation. It's going to be something like
$cnt = Jelly::select("tot")->select("count('total_item') AS total")
->where("category_id","=", 1)
->limit(1)
->execute();
echo $cnt->total;
hope that helps!
i m using following with kohana 3.1
$count = ORM::factory('items')->select(array('COUNT("id")', 'total_items'))->find_all();
Perhaps something like this would be better:
$count = Jelly::select('item')->where('category', '=', 1)->count();
This would generate this query:
SELECT COUNT(*) AS `total` FROM `items` WHERE `category_id` = 1
精彩评论