任何人都可以解释我如何只删除选中的行或所有选中的行,复选框下面有代码但是给我错误sql异常
Exception (Database Exception) 'yii\db\Exception' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' The SQL being executed was: DELETE FROMusermaster
WHEREid
='28''public function actionMultipledelete() { if (\Yii::$app->request->post()) { $keys=array(); $keys = \Yii::$app->request->post('id'); // id is array } UsermasterModel::deleteAll(['IN','id',$keys]); return $this->redirect(['index']); }
答案 0 :(得分:0)
只需使用此
即可$ keys = implode(',',$ array);
$ connection = Yii :: $ app-> db; $ command = $ connection-> createCommand(" DELETE FROM usermaster,其中id为IN (" $键")&#34);