Search code examples
phpkohanajelly

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 category_id = '1'

really appreciate your help.

thanks


Solution

  • 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