Exemple #1
0
 public function __construct($source)
 {
     parent::__construct($source);
     $object = new AssociationType($this->getSource());
     $object->loadBy('caption', 'dafault');
     $this->associationType = $object;
     $object = new ObjectType($this->getSource());
     $object->loadBy('caption', 'default');
     $this->objectType = $object;
 }
Exemple #2
0
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
ini_set('memory_limit', '-1');
$oldModel = DataSource::get('old');
$newModel = DataSource::get('new');
$ezObjectType = new ObjectType($newModel);
$ezObjectType->loadBy('qname', 'ezobject');
$defaultAssociation = new AssociationType($newModel);
$defaultAssociation->loadBy('qname', 'default');
$query = "\n    SELECT DISTINCT\n      tag.keyword,\n      association.object_id\n    FROM eztags_attribute_link association\n    JOIN eztags tag\n      ON tag.id=association.keyword_id\n\n";
$rows = $oldModel->queryAndFetch($query);
$newModel->autocommit(false);
foreach ($rows as $row) {
    $tag = new Tag($newModel);
    $tag->loadBy('caption', $row['keyword']);
    $association = new Association($newModel);
    $association->setValue('tag_id', $tag->getId());
    $association->setValue('object_id', $row['object_id']);
    $association->setObjectType($ezObjectType);
    $association->setType($defaultAssociation);
    $association->insert();
    echo $tag->getValue('caption') . "\t" . $row['object_id'] . "\n";
}
$newModel->commit();
//print_r($rows);
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
$tagDataSource = DataSource::get('old');
//selection de toutes les relations pagehub/tag de l'ancien système
$query = "SELECT * FROM eztags";
$rows = $tagDataSource->queryAndFetch($query);
$relatedAssociation = new AssociationType('new');
$relatedAssociation->loadBy('qname', 'related');
$tagType = new ObjectType('new');
$tagType->loadBy('qname', 'tag');
foreach ($rows as $values) {
    $query = "\n    SELECT\n        DISTINCT\n            originTag.id as tagId,\n            originTag.remote_id as pagehubId,\n            originTag.keyword as fromKeyword,\n            destinationTag.id as destinationId,\n            destinationTag.keyword as destinationKeyword\n    FROM eztags originTag\n    JOIN eztags_attribute_link link\n        ON link.object_id=originTag.remote_id\n    JOIN eztags destinationTag\n        ON destinationTag.id=link.keyword_id\n    WHERE originTag.id=" . $values['id'] . "\n    ";
    $relationData = $tagDataSource->queryAndFetch($query);
    if (!empty($relationData)) {
        foreach ($relationData as $values) {
            //récupération du tag d'origine dans la nouvelle bdd
            $fromTag = new Tag('new');
            $fromTag->loadBy('caption', $values['fromKeyword']);
            $relatedTag = new Tag('new');
            $relatedTag->loadBy('caption', $values['destinationKeyword']);
            //récupération pour le related tag
            if ($fromTag->getId() && $relatedTag->getId()) {
                $association = new Association('new');
                $association->setType($relatedAssociation);
                $association->setObjectType($tagType);
<?php

use PMD\Capital\Configuration\DataSource;
use PMD\Capital\Module\Tag\Model\Tag;
use PMD\Capital\Model\ObjectType;
use PMD\Capital\Module\Tag\Model\Type;
use PMD\Capital\Module\Tag\Model\Association;
use PMD\Capital\Module\Tag\Model\AssociationType;
$tagDataSource = DataSource::get('old');
$query = "\n    SELECT\n      tag.id as tagId,\n      tag.keyword as caption,\n      tag.remote_id as pagehubId\n    FROM eztags tag\n    JOIN ezcontentobject object\n      ON tag.remote_id=object.id\n\n";
$rows = $tagDataSource->queryAndFetch($query);
//récupération du type d'association pagehub
$associationType = new AssociationType('new');
$associationType->loadBy('qname', 'pagehub');
//récupération du type d'objet ezpublich
$objectType = new ObjectType('new');
$objectType->loadBy('qname', 'ezobject');
foreach ($rows as $values) {
    $tag = new Tag('new');
    $tag->loadBy('caption', $values['caption']);
    $tagValues = $tag->getValues();
    if (!empty($tagValues)) {
        $association = new Association('new');
        $association->setValue('tag_id', $tag->getId());
        $association->setValue('object_id', $values['pagehubId']);
        $association->setObjectType($objectType);
        $association->setType($associationType);
        $association->insert();
        echo $values['caption'] . "\t" . $values['pagehubId'] . "\n";
    }
}