On Yii 2.0, use updateAll() to update the implementation of the table column value to another column value of the same table
1. Use updateAll() to update the value of prev_status to the value of status, and update the value of status to 4, the table structure is shown in Figure 1
2. Based on the query builder, the code is as follows
self::updateAll(['prev_status' => 'status', 'status' => self::PLAN_TASK_STATUS_CLOSE],['in', 'plan_id', $planId]);
3. However, it does not meet the expectations. The values of prev_status are updated with 0, and the final SQL statement is as follows
update `PA_plan_task` set `prev_status`=0, `status`=4 where `plan_id` in (1, 2)
4. Based on yii\db\expression, it means a db expression that does not need to be escaped or referenced, the code is as follows
use yii\db\expression;
self::updateAll(['prev_status' => new Expression('status'), 'status' => self::PLAN_TASK_STATUS_CLOSE],['in', 'plan_id', $planId]);
5. The result is as expected, and the final generated SQL statement is as follows
update `pa_plan_task` set `prev_status`=status, `status`=4 where `plan_id` in (1, 2)
6. The operation result is as expected, as shown in Figure 2

