0

can anybody explain me how to delete only selected row or all selected row by checkbox it have below code but giving me error sql exception

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 Answer 1

0

Simply use this

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

$connection = Yii::$app->db; $command = $connection->createCommand("DELETE FROM usermaster where id IN (".$keys.")");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.