Zend_Db: How to get the number of rows from a tabl

2019-04-04 13:09发布

I want to find out how many rows are in a table. The database that I am using is a MySQL database. I already have a Db_Table class that I am using for calls like fetchAll(). But I don't need any information from the table, just the row count. How can I get a count of all the rows in the table without calling fetchAll()?

7条回答
SAY GOODBYE
2楼-- · 2019-04-04 14:13

Add count capability to your Zend_DB Object To count all table rows

public function count()
{
    return (int) $this->_table->getAdapter()->fetchOne(
        $this->_table->select()->from($this->_table, 'COUNT(id)')
    );
}
查看更多
登录 后发表回答