Select with Zend\Db\TableGateway\TableGateway with an empty table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The table queue is empty, I got this Fatal error: Uncaught exception 'Zend\Db\Adapter\Exception\InvalidQueryException' with message 'No database selected' in /.../library/Zend/Db/Adapter/Driver/Pdo/Statement.php on line 219 | |
use Zend\Db\TableGateway\TableGateway, | |
Zend\Db\Adapter\Adapter as DbAdapter; | |
$options = array( | |
'driver' => 'pdo_mysql', | |
'username' => 'queue', | |
'password' => 'xxx', | |
'dbname' => 'queue', | |
'port' => '3306', | |
'host' => 'localhost' | |
); | |
$db = new DbAdapter($options); | |
$table = new TableGateway('queue', $db); | |
$name ='test'; | |
$rowset = $table->select(array('queue_name' => $name)); | |
if (!empty($rowset)) { | |
$queue = $rowset->current(); | |
} | |
var_dump($queue); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment