There is a SQL query
DELETE FROM tbl_um_keys WHERE user_id = 6 AND module_id IN (20, 21, 31); How this request can be implemented using Yii2
Using ActiveRecord
YourModel::deleteAll(['user_id' => 6, 'module_id' => [20, 21, 31]]); Or by means of Connection
\Yii::$app->db->createCommand() ->delete('tbl_um_keys', ['user_id' => 6, 'module_id' => [20, 21, 31]]) ->execute() Something like that
$records=tbl_um_keys::find()->where(['user_id'=>6])->andWhere(['in','module_id',[20,21,31]])->all(); $records->delete(); Call to a member function delete() on a non-object - XfirabSource: https://ru.stackoverflow.com/questions/631224/
All Articles