Ejemplo n.º 1
0
 static function update_comments($type, $id, $date_, $memo_)
 {
     if ($date_ == null) {
         Pe::delete_comments($type, $id);
         Pe::add_comments($type, $id, Yii::app()->dateFormatter->format('yyyy-MM-dd', time()), $memo_);
     } else {
         $criteria = new CDbCriteria();
         $criteria->addCondition("type=" . $type);
         $criteria->addCondition("id=" . $id);
         $criteria->addCondition("date_=" . $date_);
         $comment = PeComments::model()->find($criteria);
         $comment->memo_ = $memo_;
         if (!$comment->save()) {
             throw new Exception("Gagal update comment.");
         }
     }
 }