';行计数在未缓冲的结果集中不可用';与Zend表网关


'Row count is not available in unbuffered result sets.' with Zend Table Gateway

我正在尝试使用Zend TableGateway作为我的应用程序的独立组件(而不是ZF2)。

下面是一个简单的测试脚本,只获取一些行,但我得到了错误

未缓存异常"Zend''Db''Adapter''exception''RuntimeException",消息为"行计数在未缓存的结果集中不可用"在/var/www/shared-views-slim/vendor/zendframework/zend-db/zend/db/Adapter/Driver/Mysqli/Result.php中:324

以下是我的代码:

/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 */
chdir(dirname(__DIR__));
// require composer autoloader for loading classes
require 'vendor/autoload.php';
// testing
$adapter = new Zend'Db'Adapter'Adapter(array(
    'driver' => 'Mysqli',
    'database' => 'budget_development',
    'username' => 'root',
    'password' => 'mypasswd'
));
use Zend'Db'TableGateway'TableGateway;
$accountsTable = new TableGateway('accounts', $adapter);
// search for at most 2 artists who's name starts with Brit, ascending
$rowset = $accountsTable->select();
var_dump($rowset);

有人知道我该怎么解决吗?我真的不明白它需要我做什么。

您使用了缓冲结果,通常用于大型数据集。正如你正在寻找的只是艺术家(正如你的评论所说),这是不需要的。

可能有一个ini文件集,其中包含以下内容:

  'db' => array(
   'options' => array(
    'buffer_results' => true,
   ),

(这是buffer_results部分)。

提示:看看config/autoload/global.php,它就在我的应用程序中。

也许有人能帮助这个

  'driver' => 'PdoMysql',

使用PdoMysql驱动程序。这适用于4 me