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(); }
/** * @param ChildRating $rating The ChildRating object to add. */ protected function doAddRating(ChildRating $rating) { $this->collRatings[] = $rating; $rating->setUser($this); }
/** * 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'); } }