Pregunta

¿podría ayudarme a averiguar cómo insertar función agregada usando Kohana? - módulo jalea

I.E. i necesidad de mostrar resultado de la consulta siguiente:

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

Realmente aprecio su ayuda.

gracias

¿Fue útil?

Solución

Tal vez algo como esto sería mejor:

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

Esto generaría esta consulta:

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

Otros consejos

brevemente de mirar la documentación. Va a ser algo así como

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

echo $cnt->total;

Espero que ayude!

i M usando siguiente con kohana 3.1

$ count = ORM :: factory ( 'artículos') -> seleccionar (array ( 'count ( "id")', 'TOTAL_ITEMS')) -> find_all ();

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top