124 lines
3.2 KiB
PHP
124 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace Deblan\Bundle\BlogBundle\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Output\Output;
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
|
|
class ImportOldBlogCommand extends ContainerAwareCommand
|
|
{
|
|
/**
|
|
* @see Command
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setDescription('Import olb blog\'s datas')
|
|
->setHelp(<<<EOT
|
|
EOT
|
|
)
|
|
->setName('deblan:import-blog')
|
|
;
|
|
}
|
|
|
|
/**
|
|
* @see Command
|
|
*
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
foreach(\Deblan\Bundle\BlogBundle\Model\PostQuery::create()->find() as $k => $v) {
|
|
$v->setSlug('')->save();
|
|
}
|
|
|
|
foreach(\Deblan\Bundle\BlogBundle\Model\CategoryQuery::create()->find() as $k => $v) {
|
|
$v->setSlug('')->save();
|
|
}
|
|
|
|
// $con = new \PDO('mysql:host=localhost;dbname=deblantv', 'root', 'root');
|
|
// $stmt = $con->prepare('select * from post');
|
|
// $stmt->execute();
|
|
//
|
|
// $results = $stmt->fetchAll();
|
|
|
|
// $f = function($m) { if(is_string($m)) return utf8_decode(iconv('ISO-8859-1', 'UTF-8', $m)); return $m; };
|
|
|
|
// foreach($results as $p) {
|
|
// $p = array_map($f, $p);
|
|
// $post = new \Deblan\Bundle\BlogBundle\Model\Post;
|
|
|
|
// $post
|
|
// ->setId($p['id'])
|
|
// ->setTitle($p['title'])
|
|
// ->setContent($p['content'])
|
|
// ->setActive($p['is_active'])
|
|
// ->setCreatedAt($p['created_at'])
|
|
// ->setUpdatedAt($p['updated_at'])
|
|
// ->setPublishedAt($p['published_at'])
|
|
// ->setUserId($p['user_id'])
|
|
// ->setTags($p['tags'])
|
|
// ->setPicture($p['picture'])
|
|
// ->save();
|
|
// }
|
|
//
|
|
// $stmt = $con->prepare('select * from category');
|
|
// $stmt->execute();
|
|
//
|
|
// $results = $stmt->fetchAll();
|
|
|
|
// foreach($results as $p) {
|
|
// $p = array_map($f, $p);
|
|
// $cat = new \Deblan\Bundle\BlogBundle\Model\Category;
|
|
|
|
// $cat
|
|
// ->setId($p['id'])
|
|
// ->setTitle($p['name'])
|
|
// ->setSortableRank($p['rank'])
|
|
// ->setTitle($p['name'])
|
|
// ->setActive($p['is_active'])
|
|
// ->save();
|
|
// }
|
|
|
|
// $stmt = $con->prepare('select * from post_has_category');
|
|
// $stmt->execute();
|
|
//
|
|
// $results = $stmt->fetchAll();
|
|
|
|
// foreach($results as $p) {
|
|
// $p = array_map($f, $p);
|
|
// $phc = new \Deblan\Bundle\BlogBundle\Model\PostHasCategory;
|
|
|
|
// $phc
|
|
// ->setPostId($p['post_id'])
|
|
// ->setCategoryId($p['category_id'])
|
|
// ->save();
|
|
// }
|
|
|
|
// $stmt = $con->prepare('select * from comment');
|
|
// $stmt->execute();
|
|
//
|
|
// $results = $stmt->fetchAll();
|
|
|
|
// foreach($results as $p) {
|
|
// $p = array_map($f, $p);
|
|
// $c = new \Deblan\Bundle\BlogBundle\Model\Comment;
|
|
|
|
// $c
|
|
// ->setId($p['id'])
|
|
// ->setPostId($p['post_id'])
|
|
// ->setCommentId($p['parent_comment_id'])
|
|
// ->setAuthor($p['author'])
|
|
// ->setWebsite($p['website'])
|
|
// ->setEmail($p['email'])
|
|
// ->setContent($p['content'])
|
|
// ->setCreatedAt($p['created_at'])
|
|
// ->setUpdatedAt($p['updated_at'])
|
|
// ->setActive(1)
|
|
// ->save();
|
|
// }
|
|
}
|
|
}
|