On Zend_Db_Table_Abstract I’m using this code to get the count of results for my select:
$this->setTableName('visitors');
$select = $this->select()
->from('visitors')
->columns(array('total' => new Zend_Db_Expr('COUNT(*)')))
->where('...');
$visits = $this->_fetch($select);
Is there a better way, ie, just to return the count. This returns some other data in an array… I just want the count of results. In straight mySQl the equivalent would be select count(mycol) from visitors where ....
This is untested, but should get you started:
You aren’t required to use the Table/Select interface for every query.
update: +1 to the comment from @SMka, for pointing out that this can be even simpler: