Zend_Db_Table_Abstract - Help on doing a SUM

Hello all,

I’m trying to do a SUM like so:


$select = $this->select('sum(pontos) as total')->from('desafios');
$resultado = $this->fetchRow($select);
$total = $resultado->total;

But I’m getting:
Exception ‘Zend_Db_Table_Row_Exception’ with message 'Specified column “total” is not in the row

so, is not assuming the AS…

Tried:

$select = $this->select()->from('desafios', array('sum(pontos) as total'));
$total = $this->fetchRow($select);
$total->total;
var_dump($total);

and

$select = $this->select()->from('desafios', array('sum(pontos) as total'));
 $total = $this->fetchRow($select);
 var_dump($total);

No luck either.

Any help please?

Thanks a lot,
Márcio

Actually, the last to code examples worked ok.
Spell-check issue.

:slight_smile:

Regards,
Márcio