Zend framework 函数统计zend中的查询结果

Zend framework 函数统计zend中的查询结果,zend-framework,Zend Framework,有没有其他方法可以计算查询返回的行数。下面的代码返回1,即使没有返回结果。(我正在处理ZEND) 就我所知,我一直都在做这件事 $results = $overdue_query->fetchAll(); echo count($results); 如果没有,可能代码中有其他错误,很难判断。 还可以尝试toArray()查看它是否改变了任何内容 $results = $overdue_query->fetchAll()->toArray(); echo count($resu

有没有其他方法可以计算查询返回的行数。下面的代码返回1,即使没有返回结果。(我正在处理ZEND)


就我所知,我一直都在做这件事

$results = $overdue_query->fetchAll();
echo count($results);
如果没有,可能代码中有其他错误,很难判断。 还可以尝试toArray()查看它是否改变了任何内容

$results = $overdue_query->fetchAll()->toArray();
echo count($results);

应该是这样

$this->view->overdue_query = $overdue_query->fetchAll();
 /*Get overdue count */
$this->view->overdue_count = count($this->view->overdue_query); 

//unless you're getting overdue_count in your view then you would do :
$count = count($this->overdue_query);

我同意MMC的说法,你试图数错东西。
计数($this->view->逾期\查询);应该是这样。

有没有像mysql\u num\u rows这样的函数?我很好奇
var\u dump($过期的\u查询)
的输出会返回什么。我认为您应该从fetchAll()获得一个普通数组。您可以发布吗?@drew010 fetchAll()返回一个Zend\u Db\u Table\u Rows对象。您可以使用->toArray()将其强制转换为数组。
$this->view->overdue_query = $overdue_query->fetchAll();
/*Get overdue count */
$this->view->overdue_count = count($overdue_query);//you are doing count on 
//your query and not the result of fetchAll
$this->view->overdue_query = $overdue_query->fetchAll();
 /*Get overdue count */
$this->view->overdue_count = count($this->view->overdue_query); 

//unless you're getting overdue_count in your view then you would do :
$count = count($this->overdue_query);