本文整理汇总了PHP中Queue::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Queue::model方法的具体用法?PHP Queue::model怎么用?PHP Queue::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Queue
的用法示例。
在下文中一共展示了Queue::model方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($args)
{
echo "*********************\n " . date('Y-m-d H:i:s') . "\n*********************\n";
$c = new CDbCriteria();
$c->order = 'create_time ASC';
/** @var Queue $queue */
$queue = Queue::model()->find($c);
if (!$queue) {
echo "The queue is empty\n*********************\n";
return;
}
switch ($queue->type) {
case Queue::TYPE_MAIL:
$this->handleMail($queue);
break;
}
$queue->delete();
echo "*********************\n";
}
示例2: actionIndex
public function actionIndex($limit = 5)
{
$limit = (int) $limit;
echo "Process " . $limit . " mail task...\n";
Yii::log("Process " . $limit . " mail task...\n");
$models = Queue::model()->findAll(array('condition' => 'worker = :worker AND status = :status', 'params' => array(':worker' => self::MAIL_WORKER_ID, ':status' => Queue::STATUS_NEW), 'limit' => $limit, 'order' => 'priority desc'));
echo "Find " . count($models) . " new mail task...\n";
Yii::log("Find " . count($models) . " new mail task...\n");
foreach ($models as $model) {
echo "Process mail task id = {$model->id}...\n";
Yii::log("Process mail task id = {$model->id}...\n");
if (!($data = (array) json_decode($model->task))) {
$model->status = Queue::STATUS_ERROR;
$model->notice = 'Error json_decode...';
$model->save();
echo "Error json_decode...\n";
Yii::log('Error json_decode...');
continue;
}
if (!isset($data['from'], $data['to'], $data['theme'], $data['body'])) {
$model->status = Queue::STATUS_ERROR;
$model->notice = 'Wrong data...';
$model->save();
echo "Wrong data...";
Yii::log('Wrong data...');
continue;
}
if (Yii::app()->mail->send($data['from'], $data['to'], $data['theme'], $data['body'])) {
$model->status = Queue::STATUS_COMLETED;
$model->complete_time = new CDbExpression('NOW()');
$model->save();
echo "Success send...";
Yii::log("Success send...");
continue;
}
}
}
示例3: loadModel
/**
* Возвращает модель по указанному идентификатору
* Если модель не будет найдена - возникнет HTTP-исключение.
*
* @throws CHttpException
*
* @param integer $id идентификатор нужной модели
*
* @return Queue $model
*
* @throws CHttpException If record not found
*/
public function loadModel($id)
{
if (($model = Queue::model()->findByPk($id)) === null) {
throw new CHttpException(404, Yii::t('QueueModule.queue', 'Requested page was not found.'));
}
return $model;
}
示例4: init
public function init()
{
parent::init();
$this->queueTableName = Queue::model()->tableName();
}