在Zend_Db_Table_Abstract我使用這個代碼來獲得結果的計數我的選擇:Zend_Db_Table_Abstract數
$this->setTableName('visitors');
$select = $this->select()
->from('visitors')
->columns(array('total' => new Zend_Db_Expr('COUNT(*)')))
->where('...');
$visits = $this->_fetch($select);
有沒有更好的辦法,即,只是返回計數。這會返回數組中的其他數據......我只是想要計算結果的數量。在直MySQL中相當於是select count(
mycol ) from visitors where ....
只算。 '$ count =(int)$ this-> getAdapter() - > fetchOne($ select);' try :) – SMka
'fetchOne()'獲取SQL結果第一行的第一列。 – SMka