'行计数在无缓冲的结果集中不可用.使用 Zend Table 网关 [英] 'Row count is not available in unbuffered result sets.' with Zend Table Gateway

查看:27
本文介绍了'行计数在无缓冲的结果集中不可用.使用 Zend Table 网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to use Zend TableGateway as a stand alone component with my app (not ZF2).

下面是一个简单的测试脚本,只获取一些行,但出现错误

Below is a simple test script to just fetch some rows but I get the error

未捕获的异常 'Zend\Db\Adapter\Exception\RuntimeException' 带有消息 'Row count is not available in unbuffered result sets'.在/var/www/shared-views-slim/vendor/zendframework/zend-db/Zend/Db/Adapter/Driver/Mysqli/Result.php:324

Uncaught exception 'Zend\Db\Adapter\Exception\RuntimeException' with message 'Row count is not available in unbuffered result sets.' in /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);

有谁知道我该如何解决这个问题?我真的不明白它需要我做什么.

Does anyone know how I can fix this? I don't really understand what it needs me to do.

推荐答案

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

You have used buffered results, which are normally used for big datasets. As you are looking for just to artists (as you comments say), this is not needed.

可能有一个类似以下内容的 ini 文件集:

There's probably an ini file set with something like:

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

(这是 buffer_results 部分).

(it's the buffer_results part).

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

Hint: take a look in config/autoload/global.php, that's where it was in my app.

这篇关于'行计数在无缓冲的结果集中不可用.使用 Zend Table 网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆