# HG changeset patch # User cavaliet # Date 1391100734 -3600 # Node ID 48af4fad8a44540d213ed9d2edd81c5e0f496302 # Parent 22752b3d9c35f24fc6dff6a2df6efba5dff062ee migration to real dbpedia uri diff -r 22752b3d9c35 -r 48af4fad8a44 .hgsubstate --- a/.hgsubstate Wed Jan 29 12:16:16 2014 +0100 +++ b/.hgsubstate Thu Jan 30 17:52:14 2014 +0100 @@ -1,1 +1,1 @@ -085ea4dbfeee1ff9258235625ad8f4c628198080 vendor/bundles/IRI/Bundle/WikiTagBundle +a023e0185a02e6833a3e04724b80cdf628621224 vendor/bundles/IRI/Bundle/WikiTagBundle diff -r 22752b3d9c35 -r 48af4fad8a44 app/DoctrineMigrations/Version20140129151724.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/DoctrineMigrations/Version20140129151724.php Thu Jan 30 17:52:14 2014 +0100 @@ -0,0 +1,49 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + + // First we get all tags. + $em = $GLOBALS["kernel"]->getContainer()->get( 'doctrine.orm.entity_manager' ); + $query = $em->createQuery('SELECT t FROM WikiTagBundle:Tag t ORDER BY t.label ASC');//->setMaxResults(40)->setFirstResult(5000); + $tags = $query->getResult(); + + $i = 1; + foreach($tags as $tag){ + $l = $tag->getLabel(); + $uri = WikiTagUtils::getDbpediaUri($tag->getLabel(), [], false); + $tag->setDbpediaUri($uri); + $em->persist($tag); + if( $i % 50 == 0 ){ + $em->flush(); + echo "\n FLUSH"; + } + $i++; + echo "\n$i : $l \t\t: $uri"; + } + $em->flush(); + } + + public function down(Schema $schema) + { + // this down() migration is autogenerated, please modify it to your needs + $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql"); + } +}