self::updateAll(['prev_status' => 'status', 'status' => self::PLAN_TASK_STATUS_CLOSE], ['in', 'plan_id', $planId]);
//UPDATE `pa_plan_task` SET `prev_status`=0, `status`=4 WHERE `plan_id` IN (1, 2)
- 基于 yiidbExpression,表示不需要转义或引用的DB表达式,代码如下
use yiidbExpression;
self::updateAll(['prev_status' => new Expression('status'), 'status' => self::PLAN_TASK_STATUS_CLOSE], ['in', 'plan_id', $planId]);
//UPDATE `pa_plan_task` SET `prev_status`=status, `status`=4 WHERE `plan_id` IN (1, 2)
参考:
https://www.shuijingwanwq.com/2018/06/07/2687/