Beispiel #1
0
 /**
  * 保存商品
  */
 public function save()
 {
     $newComent = new Comment();
     $newComent->setAttributes($this->attributes);
     //获得对应回复ID的信息
     $upComment = Comment::find()->where('id=:id', [':id' => $this->top_id])->one();
     if (!$upComment) {
         return FALSE;
     }
     //设置title
     $newComent->setAttribute('c_title', $this->user_id . ',' . $upComment->c_title);
     //设置to_user_id
     $newComent->setAttribute('to_user_id', $upComment->user_id);
     $newComent->setAttribute("c_type", 'pinrun');
     $newComent->setAttribute("is_public", $upComment->is_public);
     $newComent->setAttribute("c_nums", 0);
     $newComent->setAttribute("c_addtime", date('Y-m-d H:i:s'));
     if ($newComent->save()) {
         Comment::updateAllCounters(['c_nums' => 1], "id=:id", [':id' => $this->top_id]);
         return $this->top_id;
     } else {
         return FALSE;
     }
 }