本文整理汇总了PHP中app\models\Task::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::deleteAll方法的具体用法?PHP Task::deleteAll怎么用?PHP Task::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::deleteAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionDelete
/**
* Deletes an existing Task model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id = null, array $ids = null)
{
$ok_message = false;
if (!$id && $ids) {
// multiple
if (Task::deleteAll(['id' => $ids])) {
$ok_message = __('Items have been deleted successfully.');
}
} elseif ($this->findModel($id)->delete()) {
// single
$ok_message = __('Item has been deleted successfully.');
}
if ($ok_message) {
Yii::$app->session->setFlash('success', $ok_message);
// if ($referrer = Yii::$app->request->referrer) {
// return $this->redirect($referrer);
// }
}
return $this->redirect(['index']);
}
示例2: actionDelete
/**
* Deletes an existing Task model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
$parent_id = $model->id;
if (!empty($model) && $model->task_from == Yii::$app->user->getId()) {
if ($model->delete()) {
if (!empty($model->attachment)) {
@unlink('uploads/' . $old_attachment);
}
$detil = Task::find(['parent_task_id' => $parent_id])->all();
if (!empty($detil)) {
foreach ($detil as $attachmentItem) {
if (!empty($attachmentItem->attachment)) {
@unlink('uploads/' . $attachmentItem->attachment);
}
}
Task::deleteAll('parent_task_id = :parent_task_id', [':parent_task_id' => $parent_id]);
}
Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Data Tugas Berhasil Dihapus'));
} else {
Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Data Tugas Gagal Dihapus'));
}
}
return $this->redirect(['index']);
}