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

主宰稳场 提交于 2019-12-08 03:38:02

问题


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

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

Below is my code:

/**
 * 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.


回答1:


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.

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

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

(it's the buffer_results part).

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




回答2:


Maybe some one help this

  'driver' => 'PdoMysql',

Use PdoMysql driver . This Works 4 me



来源:https://stackoverflow.com/questions/26702870/row-count-is-not-available-in-unbuffered-result-sets-with-zend-table-gateway

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!