public function newForum($title, $description) { $forum = new sfSimpleForumForum(); $forum->setName($title); $forum->setDescription($description); $forum->setCategoryId($this->getId()); $forum->save(); return $forum; }
$browser = new sfTestBrowser(); $browser->initialize(); // initialize database manager $databaseManager = new sfDatabaseManager(); $databaseManager->initialize(); $con = Propel::getConnection(); // cleanup database sfSimpleForumCategoryPeer::doDeleteAll(); sfSimpleForumForumPeer::doDeleteAll(); sfSimpleForumPostPeer::doDeleteAll(); // Now we can start to test $t = new lime_test(34, new lime_output_color()); // Initialization $cat = new sfSimpleForumCategory(); $cat->save(); $forum = new sfSimpleForumForum(); $forum->setCategoryId($cat->getId()); $forum->save(); $topic = new sfSimpleForumTopic(); $topic->setTitle('This is a test'); $topic->setsfSimpleForumForum($forum); $topic->save(); $user0 = new sfGuardUser(); $user0->setUsername('me'); $user0->setPassword('me'); $user0->save(); $user1 = new sfGuardUser(); $user1->setUsername('foo'); $user1->setPassword('foo'); $user1->save(); $user2 = new sfGuardUser();
public function addsfSimpleForumForum(sfSimpleForumForum $l) { $this->collsfSimpleForumForums[] = $l; $l->setsfSimpleForumPost($this); }
/** * Selects a collection of sfSimpleForumPost objects pre-filled with related topic and forum objects. * * @return array Array of sfSimpleForumPost objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinTopicAndForum(Criteria $c, $con = null) { foreach (sfMixer::getCallables('BasesfSimpleForumPostPeer:doSelectJoinAllExcept:doSelectJoinAllExcept') as $callable) { call_user_func($callable, 'BasesfSimpleForumPostPeer', $c, $con); } $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } sfSimpleForumPostPeer::addSelectColumns($c); $startcol2 = sfSimpleForumPostPeer::NUM_COLUMNS - sfSimpleForumPostPeer::NUM_LAZY_LOAD_COLUMNS + 1; sfSimpleForumTopicPeer::addSelectColumns($c); $startcol3 = $startcol2 + sfSimpleForumTopicPeer::NUM_COLUMNS; sfSimpleForumForumPeer::addSelectColumns($c); $startcol4 = $startcol3 + sfSimpleForumForumPeer::NUM_COLUMNS; $c->addJoin(sfSimpleForumPostPeer::TOPIC_ID, sfSimpleForumTopicPeer::ID); $c->addJoin(sfSimpleForumPostPeer::FORUM_ID, sfSimpleForumForumPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $post = new sfSimpleForumPost(); $post->hydrate($rs); $topic = new sfSimpleForumTopic(); $topic->hydrate($rs, $startcol2); $newObject = true; foreach ($results as $temp_post) { $existing_topic = $temp_post->getsfSimpleForumTopic(); if ($existing_topic->getPrimaryKey() === $topic->getPrimaryKey()) { $newObject = false; $existing_topic->addsfSimpleForumPost($post); break; } } if ($newObject) { $topic->initsfSimpleForumPosts(); $topic->addsfSimpleForumPost($post); } $forum = new sfSimpleForumForum(); $forum->hydrate($rs, $startcol3); $newObject = true; foreach ($results as $temp_post) { $existing_forum = $temp_post->getsfSimpleForumForum(); if ($existing_forum->getPrimaryKey() === $forum->getPrimaryKey()) { $newObject = false; $existing_forum->addsfSimpleForumPost($post); break; } } if ($newObject) { $forum->initsfSimpleForumPosts(); $forum->addsfSimpleForumPost($post); } $results[] = $post; } return $results; }