All aggregate function are like an expression for zend framework. So we need to call them by using an instance of Zend_Db_Expr($expr). To get max id from table in zend framework is an simple example for this as explained below.
For example If you want to get max id of the table you need to use new Zend_Db_Expr(‘MAX(id) as id’).
public function getMaxId(){ $select = $this->select() ->from(array('t' => 'table'),array(new Zend_Db_Expr('MAX(id) as maxid'))); $row = $this->fetchRow($select); if(!$row){ return false; }else{ $tData = $row->toArray(); return $tData ['maxid']; } }
$this->getMaxId(); will return a max id of the table.
Hope this will help you.