Zend Queue DB Exception

199 views Asked by At

I'm using Zend_Queue with the DB adapter outside the framework, I have the following code:

<?php

set_include_path(implode(PATH_SEPARATOR, array(
    realpath('../libs'),
    get_include_path(),
)));

require_once('Zend/Queue/Adapter/Db.php');

$options = array(
    'options' => array(
        'name' => 'myqueue',
        // use Zend_Db_Select for update, not all databases can support this
        // feature.
        Zend_Db_Select::FOR_UPDATE => true
    ),
    'driverOptions' => array(
        'host'      => 'localhost',
        'username'  => 'root',
        'password'  => 'password',
        'dbname'    => 'mydb',
        'type'      => 'pdo_mysql',
    )
);

// Create a database queue.
$queue = new Zend_Queue('Db', $options);

$queue->send('test');

I get a 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound' in Zend\Db\Statement\Pdo.php:228

Any ideas what I'm doing wrong?

The $params and statement are:

array(0) {
}
object(PDOStatement)#11 (1) {
  ["queryString"]=>
  string(67) "SELECT `queue`.`queue_id` FROM `queue` WHERE (queue_name=?) LIMIT 1"
}
1

There are 1 answers

0
neilcrookes On

It turns out the currentQueue was not set. You can set this using:

$queue->setOption($queue::NAME, 'your_queue_name');

From Zend/Queue.php, in the doc block for the getName() method...

 * Note: _setName() used to exist, but it caused confusion with createQueue
 * Will evaluate later to see if we should add it back in.