Hallo @All,
ich programmiere gerade ein Migrationscript von Coppermine nach JoomGallery.
Da coppermine neben Kategorien auch mit alben arbeitet, habe ich mir überlegt eine "Hilfstabelle" zu erstellen.
Das erstellen der Tabelle klappt auch. Hier der Code.
PHP
// info $this->getHelperTableName() gibt #__coppermine_joom_migration_helper zurück
public function prepareMigrationTables(){
$this->writeLogfile('Create Migration Table '.$this->getHelperTableName());
$query = "CREATE TABLE IF NOT EXISTS ".$this->db->quoteName($this->getHelperTableName())." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`parent_id` int(10) unsigned NOT NULL DEFAULT '0',
`lft` int(11) NOT NULL DEFAULT '0',
`rgt` int(11) NOT NULL DEFAULT '0',
`level` int(10) unsigned NOT NULL DEFAULT '0',
`title` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL DEFAULT '',
`description` varchar(255) NOT NULL DEFAULT '',
`access` tinyint(3) unsigned NOT NULL DEFAULT '0',
`path` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `idx_left_right` (`lft`,`rgt`)
) DEFAULT CHARSET=utf8;";
try{
$this->db->setQuery($query);
$this->db->execute();
}
catch (Exception $e){
echo $e->getMessage();
return false;
}
return true;
}
Alles anzeigen
Was nicht klappt ist das eintrage der Daten in die NestedTable
Code
Datensatz exemplarisch:
stdClass Object
(
[description] => alles was nicht vom SCG oder seinen Mitgliedern veranstaltet wird
[lft] => 3
[rgt] => 4
[alias] =>
[id] => 4
[parent_id] => 1
[level] => 1
[title] => allgemeine Veranstaltungen
[access] => 1
[path] => |4
)
Funtion:
public function storeElementToCategoriesHelperTable($data){
$table = $this->getTable();
$this->writeLogfile('Try add ID '.$data->id.' to table '.$this->db->replacePrefix($table->getTableName()));
echo '<pre>';
print_r($data);
echo '</pre>';
try {
$table->bind($data);
}catch (Exception $e) {
JErrorPage::render($e);
return false;
}
$this->writeLogfile('ID '.$data->id.' successfull bind to table '.$this->db->replacePrefix($table->getTableName()));
try{
$table->check();
}catch (Exception $e) {
JErrorPage::render($e);
return false;
}
$this->writeLogfile('ID '.$data->id.' successfull checked to table '.$this->db->replacePrefix($table->getTableName()));
try{
$table->store();
}catch (Exception $e) {
JErrorPage::render($e);
return false;
}
$this->writeLogfile('ID '.$data->id.' successfull store to table '.$this->db->replacePrefix($table->getTableName()));
return true;
}
Alles anzeigen
Code
Funtion getTable():
public function getTable(){
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_joomgallery/helpers/migration/');
return JTable::getInstance('CoppermineCategories', 'Table', array());
}
Code
copperminecategories.php
class TableCoppermineCategories extends JTableNested
{
/** @var int Primary key */
var $id = 0;
function __construct(&$db){
parent::__construct( '#__coppermine_joom_migration_helper', 'id', $db );
}
}
Alles anzeigen
Was mich am meisten irritiert ist, das laut Lof-File alles klappt.
Code
#Date: 2019-08-09 13:26:41 UTC
#Software: Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
#Fields: datetime priority message
2019-08-09T13:26:55+00:00 INFO Create Migration Table #__coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO Migration Step started
2019-08-09T13:26:57+00:00 INFO max. execution time: 30 seconds
2019-08-09T13:26:57+00:00 INFO calculated refresh time: 20 seconds
2019-08-09T13:26:57+00:00 INFO *****************************
2019-08-09T13:26:57+00:00 INFO Start migrate Coppermine Album to Coppermine Category
2019-08-09T13:26:57+00:00 INFO Copy Entry id (1) from cpg_categories to lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO Try add ID 1 to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO ID 1 successfull bind to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO ID 1 successfull checked to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO ID 1 successfull store to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO Copy Entry id (4) from cpg_categories to lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO Try add ID 4 to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO ID 4 successfull bind to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO ID 4 successfull checked to table lkxqd_coppermine_joom_migration_helper
2019-08-09T13:26:57+00:00 INFO ID 4 successfull store to table lkxqd_coppermine_joom_migration_helper
Alles anzeigen
Ich sehe wohl den Wald vor lauter Bäumen nicht.
Grüsskes
togo