<?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; use PMD\Capital\Module\Tag\Model\EzPublish\Tag as EzTag; $model = DataSource::get('tag'); $newModel = DataSource::get('new'); $treeTag = new Tag($newModel); $rootTag = $treeTag->getRoot(); $query = "\n SELECT\n tag.id,\n tag.parent_id,\n tag.main_tag_id,\n tag.keyword,\n slug.slug\n\n\n FROM " . EzTag::getTableName() . " tag\n JOIN pmd_tagslug slug\n ON slug.id_tag=tag.id\n "; $rows = $model->queryAndFetch($query); $oldTags = array(); foreach ($rows as $row) { $oldTags[$row['id']] = $row; } $newTagMapping = array(); $newModel->autocommit(false); foreach ($oldTags as $row) { $tag = new Tag(); $tag->setSource($newModel); $tag->setCaption($row['keyword']); $tag->setSlug($row['slug']); $tag->insert(); $newTagMapping[$row['id']] = $tag->getId(); echo $tag->getId() . "\t" . $row['keyword'] . "\n"; } foreach ($newTagMapping as $oldId => $newId) {