facebook twitter hatena line email

「Php/zend framework/zend queue/dbモデル」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(ページの作成:「-batch/sample.php require_once APPLICATION_PATH . '/models/que/TestsQue.php'; $que = new TestsQue(); $messages = $que->receive(5); foreach ($messages as $i => $messag...」)
 
(相違点なし)

2016年3月19日 (土) 18:57時点における最新版

-batch/sample.php

require_once APPLICATION_PATH . '/models/que/TestsQue.php';
$que = new TestsQue();
$messages = $que->receive(5);
foreach ($messages as $i => $message) {
   echo $message->body, "\n";
   $que->deleteMessage($message);
}
$que->send("My Test Message");

-models/que/AbstractQue.php

abstract class AbstractQue extends Zend_Queue
{
 protected $_name = "";
 public function __construct()
 {
   if (!$this->_name) return;
   $config = ConfigModel::getInstance(APPLICATION_PATH . '/configs/db.ini', APPLICATION_ENV);
   $driverOptions = $config->default->params->toArray();
   $driverOptions['type'] = $config->default->adapter;
   $options = array(
     'driverOptions' => $driverOptions,
     'options' => array(
       Zend_Db_Select::FOR_UPDATE => true
     ),
     'name' => $this->_name,
   );
   parent::__construct('Db', $options);
 }
 public function count()
 {
   return count($this);
 }
}

-models/que/TestsQue.php

require_once __DIR__ . '/AbstractQue.php';
class TestsQue extends AbstractQue
{
  protected $_name = "queue1";
}