无法删除yii2中所有选中的复选框行

时间:2016-10-21 06:14:41

标签: yii2-advanced-app

任何人都可以解释我如何只删除选中的行或所有选中的行,复选框下面有代码但是给我错误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 FROM usermaster WHERE id='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']); }

1 个答案:

答案 0 :(得分:0)

只需使用此

即可
  

$ keys = implode(',',$ array);

     

$ connection = Yii :: $ app-> db; $ command =   $ connection-> createCommand(" DELETE FROM usermaster,其中id为IN   (" $键")&#34);