public static function setIsNewForUser($topics, $user_id) { $topic_ids = array(); $topic_hash = array(); foreach ($topics as $topic) { // A topic is new unless we can find a view from the user for it $topic->setIsNew(true); $id = $topic->getId(); $topic_ids[] = $id; $topic_hash[$id] = $topic; } $c = new Criteria(); $c->clearSelectColumns(); $c->addSelectColumn(sfSimpleForumTopicViewPeer::TOPIC_ID); $c->add(sfSimpleForumTopicViewPeer::USER_ID, $user_id); $c->add(sfSimpleForumTopicViewPeer::TOPIC_ID, $topic_ids, Criteria::IN); $rs = sfSimpleForumTopicViewPeer::doSelectRS($c); while ($rs->next()) { $topic = $topic_hash[$rs->getInt(1)]; $topic->setIsNew(false); } return $topic_hash; }
public function clearViews() { $c = new Criteria(); $c->add(sfSimpleForumTopicViewPeer::TOPIC_ID, $this->getId()); sfSimpleForumTopicViewPeer::doDelete($c); }
public static function retrieveByPK($user_id, $topic_id, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(); $criteria->add(sfSimpleForumTopicViewPeer::USER_ID, $user_id); $criteria->add(sfSimpleForumTopicViewPeer::TOPIC_ID, $topic_id); $v = sfSimpleForumTopicViewPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }
public function getsfSimpleForumTopicViewsJoinsfSimpleForumTopic($criteria = null, $con = null) { include_once 'lib/model/om/BasesfSimpleForumTopicViewPeer.php'; if ($criteria === null) { $criteria = new Criteria(); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collsfSimpleForumTopicViews === null) { if ($this->isNew()) { $this->collsfSimpleForumTopicViews = array(); } else { $criteria->add(sfSimpleForumTopicViewPeer::USER_ID, $this->getId()); $this->collsfSimpleForumTopicViews = sfSimpleForumTopicViewPeer::doSelectJoinsfSimpleForumTopic($criteria, $con); } } else { $criteria->add(sfSimpleForumTopicViewPeer::USER_ID, $this->getId()); if (!isset($this->lastsfSimpleForumTopicViewCriteria) || !$this->lastsfSimpleForumTopicViewCriteria->equals($criteria)) { $this->collsfSimpleForumTopicViews = sfSimpleForumTopicViewPeer::doSelectJoinsfSimpleForumTopic($criteria, $con); } } $this->lastsfSimpleForumTopicViewCriteria = $criteria; return $this->collsfSimpleForumTopicViews; }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = sfSimpleForumTopicViewPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setUserId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setTopicId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setCreatedAt($arr[$keys[2]]); } }