Skip to content

Instantly share code, notes, and snippets.

@ezimuel
Created May 2, 2012 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ezimuel/2577720 to your computer and use it in GitHub Desktop.
Save ezimuel/2577720 to your computer and use it in GitHub Desktop.
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