phpzend-frameworkzend-queue

Zend_Queue database scheme


I'm using Zend_Queue to queue and send out emails (http://framework.zend.com/manual/en/zend.queue.adapters.html)

Is there a way to modify the Zend_Queue_Adapter_Db default table names? By default, the table names are "queue" & "message" which are a little confusing and I would like to name them queues and queues_messages.


Solution

  • Those table names appear to be hardcoded as default property values with no built-in mutators, but you can probably override Zend_Queue_Adapter_Db to do your bidding. This code is untested, but something like the following:

    class My_Queue_Adapter_Db extends Zend_Queue_Adapter_Db
    {
        public function __construct($options, Zend_Queue $queue = null)
        {
            parent::__construct($options, $queue);
            if (isset($options['queueTableName']) {
                $this->_queueTable->setOptions(
                    array(Zend_Db_Table_Abstract::NAME => $options['queueTableName'])
                );
            }
        }
    }
    

    Then just pass a 'queueTableName' property to the constructor. Same principles applies to the _messageTable property.