0

我在框架外使用 Zend_Queue 和 DB 适配器,我有以下代码:

<?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');

我进去'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound'Zend\Db\Statement\Pdo.php:228

任何想法我做错了什么?

$params 和语句是:

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

1 回答 1

0

事实证明 currentQueue 没有设置。您可以使用以下方法进行设置:

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

来自 Zend/Queue.php,在 getName() 方法的 doc 块中...

 * Note: _setName() used to exist, but it caused confusion with createQueue
 * Will evaluate later to see if we should add it back in.
于 2012-08-20T20:08:14.010 回答