where([ 'id'=>$id, 'su_id'=>$this->su_id, 'u_id'=>$this->u_id ])->one(); if (!$userComment) throw new Exception('评价不存在'); $userComment->delete(); } public function edit($id) { if (!$this->validate()){ throw new Exception($this->getErrorMsg($this)); } $userComment=UserComment::find()->where([ 'id'=>$id, 'su_id'=>$this->su_id, 'u_id'=>$this->u_id ])->one(); if (!$userComment) throw new Exception('评价不存在'); UserComment::updateAll(['score'=>$this->score,'comment'=>$this->comment],['id'=>$id,'su_id'=>$this->su_id, 'u_id'=>$this->u_id]); } }