Php Yii 2更新所有不在

Php Yii 2更新所有不在,php,yii,yii2,yii2-model,Php,Yii,Yii2,Yii2 Model,根据下面的代码,我想将所有客户更新为状态1,其中状态=2。但是,我想运行下面的代码,其中customer_id不在(1、3、5、8)中 我如何才能做到这一点?条件的格式可以是您在->where()中输入的格式,因此在您的情况下: $customerNotIn = array(1, 3, 5 ,8); Customer::updateAll(['status' => 1], ['AND', 'status = 2', ['NOT IN', 'status', $custo

根据下面的代码,我想将所有客户更新为状态1,其中状态=2。但是,我想运行下面的代码,其中customer_id不在(1、3、5、8)中


我如何才能做到这一点?

条件的格式可以是您在
->where()
中输入的格式,因此在您的情况下:

$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], ['AND', 
    'status = 2', 
    ['NOT IN', 'status', $customerNotIn]
]);

这是不对的。这将变为状态1,而不是1,3,5,8。我想要的是将状态更改为2。但不是在customer_id=1,3,5,8中,您的意思是您需要这两个条件?我不明白。最终状态应该是什么以及在什么条件下?使用
操作符来确定条件,就像在where块中一样
$customerNotIn = array(1, 3, 5 ,8);
Customer::updateAll(['status' => 1], ['AND', 
    'status = 2', 
    ['NOT IN', 'status', $customerNotIn]
]);