Exemplo n.º 1
0
 public function like($cid)
 {
     $ex = RatingQuery::create()->filterByIdUser($_SESSION["user"]->getId())->filterByIdComment($cid)->findOne();
     $comment = CommentQuery::create()->findPk($cid);
     if ($ex == NULL) {
         $like = new Rating();
         $like->setIdUser($_SESSION["user"]->getId());
         $like->setIdComment($cid);
         $like->save();
         $comment->setLikeCount($comment->getLikeCount() + 1);
         $comment->save();
     }
     echo $comment->getLikeCount();
 }
Exemplo n.º 2
0
 /**
  * @param ChildRating $rating The ChildRating object to add.
  */
 protected function doAddRating(ChildRating $rating)
 {
     $this->collRatings[] = $rating;
     $rating->setUser($this);
 }
Exemplo n.º 3
0
 /**
  * Filter the query by a related \Models\Rating object
  *
  * @param \Models\Rating|ObjectCollection $rating the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildUserQuery The current query, for fluid interface
  */
 public function filterByRating($rating, $comparison = null)
 {
     if ($rating instanceof \Models\Rating) {
         return $this->addUsingAlias(UserTableMap::COL_ID, $rating->getIdUser(), $comparison);
     } elseif ($rating instanceof ObjectCollection) {
         return $this->useRatingQuery()->filterByPrimaryKeys($rating->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByRating() only accepts arguments of type \\Models\\Rating or Collection');
     }
 }