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()
?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
I'm kind of a minimalist:
Can be used generically on all tables.
Counting rows with
fetchAll
considered harmful.Here's how to do it the Zend_Db_Select way:
Proper Zend-Way is to use Zend_Db_Select like this:
This is how it's done in Zend_Paginator. Other option is to add
SQL_CALC_FOUND_ROWS
before your column list and then get the number of found rows with this query:You could do a