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:
PHP
self::updateAll(['prev_status' => 'status', 'status' => self::PLAN_TASK_STATUS_CLOSE], ['in', 'plan_id', $planId]);
3. However, this did not work as expected; all values of prev_status were updated with 0. The final generated SQL statement is as follows:
SQL
UPDATE `pa_plan_task` SET `prev_status`=0, `status`=4 WHERE `plan_id` IN (1, 2)
4. Based on yii\db\Expression, which represents a DB expression that does not require escaping or quoting, the code is as follows:
PHP
use yii\db\Expression;
self::updateAll(['prev_status' => new Expression('status'), 'status' => self::PLAN_TASK_STATUS_CLOSE], ['in', 'plan_id', $planId]);
5. The result meets expectations. The final generated SQL statement is as follows:
SQL
UPDATE `pa_plan_task` SET `prev_status`=status, `status`=4 WHERE `plan_id` IN (1, 2)
6. The operation result meets expectations, as shown in Figure 2.

