如何获取查询结果的sum字段的值?
$q = Doctrine_Query::create()
->select('SUM( t.field1)')
->from('table')
->group_bt('t.field2');
我试过$q->sum
之类的东西,但没有用。
我想你在第4行拼错了,应该是-
$q = Doctrine_Query::create()
->select('SUM( t.field1) AS sum')
->from('table')
->groupBy('t.field2');
$sun_value=$q->sum;