这很奇怪,但这很有效:
$oSelect = $oTable->select()
->where(...)
->order(...)
->limit(...)
$oRows = $oTable->fetchAll($oSelect);
// these two lines are the solution: we simply run the query again!
$db->query($oSelect);
$iTotal = $db->fetchOne("select FOUND_ROWS()");
我应该提到我在我的配置文件中使用了这一行:
db.profiler.enabled = true
这是一些羽毛创意的代码;但是它不起作用:
$query = $db->select()
->from('your_table', array(new Zend_Db_Expr('SQL_CALC_FOUND_ROWS id as fake_column'),'*'))
->where(...)
->limit(0, 10);
$db->query($query);
$iCount = $db->fetchOne('select FOUND_ROWS()');
也看看http://old.nabble.com/RE:-CALC_FOUND_ROWS-vs.-count%28 *%29-p16761518.html