關於yii中刪除單個數據的操作

 /**
     * 刪除圖片
     */
    public function actionDel() {
        $request = new Request();
        $id = $request->get('id');
    	$mode =  new YkImage();
		$res = $model->findOne(['id'=>$id])->delete();//刪除方法
        if ($model) {
            $model->load($request->post());
            $model->is_del = 1;
            $model->save();
            $error = $model->getErrors();
            if (empty($error)) {
                return $this->redirect(Url::to('list'));
            }

        }
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章