Yii 2 更新全部不在
Yii 2 Update All Not IN
根据下面的代码,我想将所有客户更新为状态 1,其中状态 = 2。但是,我想 运行 下面的代码,其中 customer_id 不在 (1, 3, 5, 8).
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], 'status = 2');
我怎样才能做到这一点?
条件可以采用您在 ->where()
中输入的格式,因此在您的情况下为:
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], ['AND',
'status = 2',
['NOT IN', 'status', $customerNotIn]
]);
根据下面的代码,我想将所有客户更新为状态 1,其中状态 = 2。但是,我想 运行 下面的代码,其中 customer_id 不在 (1, 3, 5, 8).
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], 'status = 2');
我怎样才能做到这一点?
条件可以采用您在 ->where()
中输入的格式,因此在您的情况下为:
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], ['AND',
'status = 2',
['NOT IN', 'status', $customerNotIn]
]);