/** * After Delete method, decriments the comment count of the parent content * @return bool */ public function afterDelete() { $content = Content::model()->findByPk($this->content_id); if ($content === NULL) { return true; } $content->comment_count = $content->comment_count = max($content->comment_count - 1, 0); $content->save(); return parent::afterDelete(); }