Hi,
I need to create a SQL like this:
Select fk_plan_de_cuenta_id, SUM(ingreso)
from t_caja
Order by fk_plan_de_cuenta_id
Group by fk_plan_de_cuenta_id
And I’m using CDbCriteria: and model()->findAllByAttribute
$cond = new CDbCriteria;
$cond->order = 'fecha_mov ASC, fk_plan_de_cuenta_id ASC, fk_familia_id ASC, fk_alumno_id ASC ';
$cond->condition = 'ingreso > 0 and egreso = 0';
$cond->group = 'fk_plan_de_cuenta_id ';
$cond->select = 'fk_plan_de_cuenta_id, sum(ingreso) AS SUMingreso';
and then retrieve data:
$movCaja = Caja::model()->findAllByAttributes(array('fecha_mov'=>$printCajaForm->fecha), $cond);
The problem is that I receive AR objects …
So I never get "SUMingreso" fields …
Maybe I’m confuse and I have to use SQL only ?
Is there any way of using CDbCriteria instead ??
Best Regards