/** * @see sfTask */ protected function executeTask($env, $arguments = array(), $options = array()) { $sql = "SELECT ft.id AS id,\n ft.subject as title,\n ft.posted as posted\n FROM forum_topics AS ft\n WHERE ft.forum_id=3\n ORDER BY ft.posted ASC"; $connection = Propel::getConnection(); $statement = $connection->prepare($sql); $statement->execute(); while ($resultset = $statement->fetch(PDO::FETCH_ASSOC)) { $id = $resultset['id']; $title = $resultset['title']; $sql2 = "SELECT message AS description\n FROM forum_posts\n WHERE topic_id={$id}\n ORDER BY posted DESC\n LIMIT 0,1"; $connection2 = Propel::getConnection(); $statement2 = $connection2->prepare($sql2); $statement2->execute(); $resultset2 = $statement2->fetch(PDO::FETCH_ASSOC); $description = nl2br($resultset2['description']); $description = preg_replace('!\\[url[^]]*\\]([^\\[]*)\\[/url\\]!', '<a href="\\1">\\1</a>', $description); $createdAt = date('Y-m-d H:i:s', $resultset['posted']); $forumUrl = "http://www.plancake.com/forums/topic/{$id}/" . PcUtils::slugify($title); $blogPost = new PcBlogPost(); $blogPost->setTitle($title)->setContent($description)->setCreatedAt($createdAt)->setUserId(4)->setSlug(PcUtils::slugify($title))->setForumUrl($forumUrl)->save(); $blogPostCategory = new PcBlogCategoriesPosts(); $blogPostCategory->setPostId($blogPost->getId())->setCategoryId(1)->save(); if (strpos($title, "Plancake will be down for scheduled maintenance of server") !== FALSE) { $blogPostCategory = new PcBlogCategoriesPosts(); $blogPostCategory->setPostId($blogPost->getId())->setCategoryId(4)->save(); } } echo "\nDone migration to 1.9.0 \n\n"; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param PcBlogPost $value A PcBlogPost object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(PcBlogPost $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
/** * Declares an association between this object and a PcBlogPost object. * * @param PcBlogPost $v * @return PcBlogComment The current object (for fluent API support) * @throws PropelException */ public function setPcBlogPost(PcBlogPost $v = null) { if ($v === null) { $this->setPostId(NULL); } else { $this->setPostId($v->getId()); } $this->aPcBlogPost = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the PcBlogPost object, it will not be re-added. if ($v !== null) { $v->addPcBlogComment($this); } return $this; }