public function actionDelete($id) { $this->findModel($id)->delete(); return $this->redirect(['index']); } |
2 answers
DELETE, INSERT queries are "one-way" queries. They return true or false, and this was not successfully removed or an error occurred during the deletion, which means that the request was simply completed.
To check whether the record was deleted or not - you can try to remove it again after deleting, well check the number of records with such ID. I have not studied uii yet, but I think there should be an analogue of such a function:
mysqli_affected_rows($link);// Возвращает число строк, затронутых последним INSERT, UPDATE, REPLACE или DELETE запросом. |
if ( $this->findModel($id)->delete() ) { return $this->redirect(['index']); } |