/** * @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"; }