Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Select with Zend\Db\TableGateway\TableGateway with an empty table
// 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