/**
  * @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";
 }
 public function savePcBlogCategoriesPostsList($con = null)
 {
     if (!$this->isValid()) {
         throw $this->getErrorSchema();
     }
     if (!isset($this->widgetSchema['pc_blog_categories_posts_list'])) {
         // somebody has unset this widget
         return;
     }
     if (null === $con) {
         $con = $this->getConnection();
     }
     $c = new Criteria();
     $c->add(PcBlogCategoriesPostsPeer::POST_ID, $this->object->getPrimaryKey());
     PcBlogCategoriesPostsPeer::doDelete($c, $con);
     $values = $this->getValue('pc_blog_categories_posts_list');
     if (is_array($values)) {
         foreach ($values as $value) {
             $obj = new PcBlogCategoriesPosts();
             $obj->setPostId($this->object->getPrimaryKey());
             $obj->setCategoryId($value);
             $obj->save();
         }
     }
 }
 /**
  * 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      PcBlogCategoriesPosts $value A PcBlogCategoriesPosts object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PcBlogCategoriesPosts $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getPostId(), (string) $obj->getCategoryId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }