shop-old/scripts/import_topreef/item_structure.php
2026-04-20 01:03:43 +02:00

39 lines
1.0 KiB
PHP

<?php
//ini_set("memory_limit","1024M");
//set_time_limit(60000);
// new database
$connection=mysql_connect('localhost', 'root', '1234') or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db('topreef', $connection) or die("Konnte die Datenbank nicht waehlen2.");
echo "get structure<br>";
// get structure
$sql = "SELECT * FROM structure";
$query = mysql_query($sql);
$structure = array();
while($obj = mysql_fetch_object($query)) {
$structure[$obj->old_id] = $obj->id;
}
echo "get import<br>";
// get imports
$sql = "SELECT * FROM itemgroup_import";
$query = mysql_query($sql);
$imports = array();
while($obj = mysql_fetch_object($query)) {
$imports[] = $obj;
}
echo "imports<br>";
foreach ($imports as $import) {
//$sql = "UPDATE items SET structure_id='".$structure[$import->group_id]."' WHERE id=".$import->item_id;
$sql = "INSERT INTO item_structure_assign SET structure_id='".$structure[$import->group_id]."', item_id=".$import->item_id;
$query = mysql_query($sql);
if (!$query) {
echo $sql;
echo "<br />";
}
}