$params = [':roleid' => 123, ':permid' => '8,12']];
Yii::$app->db->createCommand()->delete(AdminRolePerm::tableName(), 'roleid=:roleid AND permid IN (:permid)',
$params)
->execute();
如果将 execute()换成 getRawSql(); 是可以输出正常执行的sql的。可是使用execute()就会报如下错误:
Exception (Database Exception) 'yii\db\Exception' with message 'Undefined offset: 1
Failed to prepare SQL: DELETE FROM `t_admin_role_perm` WHERE roleid=:roleid AND permid IN (:permid)'
in basic_admin\vendor\yiisoft\yii2\db\Command.php:230