Symfony: Doctrine Query SUM

Doctrine orderBy on SUM() field with alias

$q = Doctrine_Query::create()
->select(‘sum(yourTableFieldName)’)
->from (‘yourTable’)
->where (‘yourTableFieldName1=?’, 1)
->andWhere (‘yourTableFieldName2=?’, 1)
;

$result = $q->execute(array(), Doctrine::HYDRATE_SCALAR);

if (!empty ($result[0]['yourTable_sum'])) {
return $result[0]['yourTable_sum'];
}

return 0;