Clo*_*eph 3 php yii yii2 yii2-model
根据下面的代码,我想将 customer 中的所有内容更新为 status = 2 的状态 1。但是,我想运行下面的代码,其中 customer_id 不在 (1, 3, 5, 8) 中。
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], 'status = 2');
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
条件可以采用您放入 a 的格式->where(),因此在您的情况下是:
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], ['AND',
'status = 2',
['NOT IN', 'status', $customerNotIn]
]);
Run Code Online (Sandbox Code Playgroud)