'Row count is not available in unbuffered resu

2019-06-12 02:01发布

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.

2条回答
唯我独甜
2楼-- · 2019-06-12 02:37

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.

查看更多
何必那么认真
3楼-- · 2019-06-12 02:41

Maybe some one help this

  'driver' => 'PdoMysql',

Use PdoMysql driver . This Works 4 me

查看更多
登录 后发表回答