I use something like this
$select = $rs->select(); $row = $rs->getAdapter()->query($select)->rowCount(); echo ('number of rows in my table is '.$row); Hector Virgen wrote:
What would be the best way to count the number of records in a table, with or without a where clause? The docs say you can query a rowset and then use count() in PHP to count the records returned, but I don't believe this to be the most efficient way to do a simple count (especially if your SQL server and PHP server are on two different boxes). http://framework.zend.com/manual/en/zend.db.table.rowset.html $rowset = $bugs->fetchAll("bug_status = 'FIXED'"); $rowCount = count($rowset); I'm basically looking for something more like: $rowCount = $bugs->count("bug_status = 'FIXED'); The SQL query should look more like "SELECT COUNT(id) FROM bugs WHERE bug_status = 'FIXED'" Or, if possible, I'd like to make use of MySQL's SQL_CAL_FOUND_ROWS and FOUND_ROWS() functions. Any suggestions on how to do this without having to write my own SQL statements?
View this message in context:
Re: Efficiently counting rows Sent from the
Zend DB mailing list archive at Nabble.com.
没有评论:
发表评论