Domanda

mi potrebbe aiutare a scoprire come inserire funzione di aggregazione utilizzando Kohana -? Modulo Jelly

vale a dire. ho bisogno di mostrare risultato della seguente query:

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

davvero apprezzare il vostro aiuto.

grazie

È stato utile?

Soluzione

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

Altri suggerimenti

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();

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top