首页 > 其他 > 详细

yii框架学习 6-1 console 命令行

时间:2020-04-28 15:38:48      阅读:57      评论:0      收藏:0      [点我收藏+]

 

1、命令带参数

技术分享图片

 

 

 

2、定时任务脚本例子 

<?php

namespace console\controllers;
use common\models\Postware;

/**
 * 定时关闭订单任务脚本
 * Class SemihCloseOrderController
 * @package console\controllers
 */
class SemihCloseOrderController extends \yii\console\Controller
{
    public function actionIndex(){
        $postware = Postware::find()->select(["id"])->where([‘<‘, ‘created_at‘, date("Y-m-d H:i:s", time()-30*60)])->andWhere([‘in‘,‘state‘, [0,1]])->asArray()->all();
        $ids = array_column($postware, ‘id‘);
        $res = Postware::updateAll([‘state‘=>12],[‘in‘,‘id‘, $ids]);
        file_put_contents(__DIR__."/../../../runtimes/console/logs/SemihCloseOrder.log", date("Y-m-d H:i:s", time())."--close postware_id:".var_export($ids,true).PHP_EOL, FILE_APPEND);

    }
}

3、控制台命令的选项

技术分享图片

 

yii框架学习 6-1 console 命令行

原文:https://www.cnblogs.com/gaogaoxingxing/p/12794106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!