|
I’ve just started playing with Zend\Db\TableGateway, and I’m running into this exception when doing simple selects using the Mysqli driver: Row count is not available in unbuffered result sets. For example, here is one of the problem lines inside my table gateway class: $row = $this->select(array('username' => $username))->current(); If I simply add: $result->buffer(); as line 236 of Zend\Db\TableGateway\AbstractTableGateway, the problem goes away and everything works as expected. Obviously, modifying the framework is not the correct solution to the problem. I can’t seem to find any mention of result buffering in the current documentation, and I don’t see any obvious configuration options that solve the problem.
Is this a bug in the framework, or am I just missing a simple workaround? In case more detail is needed to identify the problem, here is my backtrace: #0 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/ResultSet/AbstractResultSet.php(53): Zend\Db\Adapter\Driver\Mysqli\Result->count() #1 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php(239): Zend\Db\ResultSet\AbstractResultSet->initialize(Object(Zend\Db\Adapter\Driver\Mysqli\Result)) #2 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php(210): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select)) #3 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php(197): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select)) #4 /stage/local/vufind3/module/VuFind/src/VuFind/Db/Table/User.php(60): Zend\Db\TableGateway\AbstractTableGateway->select(Array) #5 /stage/local/vufind3/module/VuFind/src/VuFind/Auth/Database.php(69): VuFind\Db\Table\User->getByUsername('dkatz', false) #6 /stage/local/vufind3/module/VuFind/src/VuFind/Account/Manager.php(219): VuFind\Auth\Database->authenticate(Object(Zend\Stdlib\Parameters)) #7 /stage/local/vufind3/module/VuFind/src/VuFind/Controller/MyResearchController.php(66): VuFind\Account\Manager->login(Object(Zend\Stdlib\Parameters)) #8 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/Controller/AbstractActionController.php(150): VuFind\Controller\MyResearchController->homeAction() #9 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent)) #10 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) #11 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #12 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/Controller/AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #13 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response)) #14 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent)) #15 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) #16 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #17 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/Application.php(317): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #18 /stage/local/vufind3/public/index.php(56): Zend\Mvc\Application->run() #19 {main}
…and here is all of my code: http://vufind.git.sourceforge.net/git/gitweb-index.cgi thanks, Demian |
|
Clearly I spent too long staring at this problem yesterday and completely missed the Adapter constructor parameter that fixes it. In case anyone else runs into this, see my adapter factory here for a solution: (The switch at the end that populates the options parameter sent to the Adapter constructor is the relevant bit). - Demian From: Demian Katz
I’ve just started playing with Zend\Db\TableGateway, and I’m running into this exception when doing simple selects using the Mysqli driver: Row count is not available in unbuffered result sets. For example, here is one of the problem lines inside my table gateway class: $row = $this->select(array('username' => $username))->current(); If I simply add: $result->buffer(); as line 236 of Zend\Db\TableGateway\AbstractTableGateway, the problem goes away and everything works as expected. Obviously, modifying the framework is not the correct solution to the problem. I can’t seem to find any mention of result buffering in the current documentation, and I don’t see any obvious configuration options that solve the problem.
Is this a bug in the framework, or am I just missing a simple workaround? In case more detail is needed to identify the problem, here is my backtrace: #0 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/ResultSet/AbstractResultSet.php(53): Zend\Db\Adapter\Driver\Mysqli\Result->count() #1 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php(239): Zend\Db\ResultSet\AbstractResultSet->initialize(Object(Zend\Db\Adapter\Driver\Mysqli\Result)) #2 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php(210): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select)) #3 /stage/local/vufind3/vendor/ZF2/library/Zend/Db/TableGateway/AbstractTableGateway.php(197): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select)) #4 /stage/local/vufind3/module/VuFind/src/VuFind/Db/Table/User.php(60): Zend\Db\TableGateway\AbstractTableGateway->select(Array) #5 /stage/local/vufind3/module/VuFind/src/VuFind/Auth/Database.php(69): VuFind\Db\Table\User->getByUsername('dkatz', false) #6 /stage/local/vufind3/module/VuFind/src/VuFind/Account/Manager.php(219): VuFind\Auth\Database->authenticate(Object(Zend\Stdlib\Parameters)) #7 /stage/local/vufind3/module/VuFind/src/VuFind/Controller/MyResearchController.php(66): VuFind\Account\Manager->login(Object(Zend\Stdlib\Parameters)) #8 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/Controller/AbstractActionController.php(150): VuFind\Controller\MyResearchController->homeAction() #9 [internal function]: Zend\Mvc\Controller\AbstractActionController->execute(Object(Zend\Mvc\MvcEvent)) #10 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) #11 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #12 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/Controller/AbstractActionController.php(117): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #13 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/DispatchListener.php(151): Zend\Mvc\Controller\AbstractActionController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response)) #14 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent)) #15 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(465): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) #16 /stage/local/vufind3/vendor/ZF2/library/Zend/EventManager/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #17 /stage/local/vufind3/vendor/ZF2/library/Zend/Mvc/Application.php(317): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure)) #18 /stage/local/vufind3/public/index.php(56): Zend\Mvc\Application->run() #19 {main}
…and here is all of my code: http://vufind.git.sourceforge.net/git/gitweb-index.cgi thanks, Demian |
| Powered by Nabble | Edit this page |
