<?php

//ini_set("memory_limit","1024M");
set_time_limit(6000000);


$connection=mysql_connect('localhost', 'root', '1234') or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db('intelectra_shop__', $connection) or die("Konnte die Datenbank nicht waehlen.1");

$query = mysql_query('select * from manufacturers') or die("Anfrage nicht erfolgreich");
$manufacturers = array();
while($obj = mysql_fetch_object($query)) {
	$manufacturers[$obj->name] = $obj->id;
}

echo "get data<br>";
// get items
$query = mysql_query('SELECT * FROM import_items') or die("Anfrage nicht erfolgreich");
$data = array();
while($obj = mysql_fetch_object($query)) {
	$data[] = $obj;
}

echo "imports<br>";
foreach ($data as $object) {
    $manufacturer_id = 0;
    if(isset($manufacturers[$object->ersatzteilvertreiber])) {
        $manufacturer_id = $manufacturers[$object->ersatzteilvertreiber];
    }
		$sql = "
			UPDATE items
			SET
				attribute_14='".mysql_real_escape_string($object->lieferzeit)."',
                                attribute_15='".mysql_real_escape_string($object->veh)."',
                                attribute_16='".mysql_real_escape_string($object->meh)."'
                        WHERE number='".$object->produktid."'
		";
                //echo $sql.'<br>';
		$query = mysql_query($sql);
		if (!$query) {
			echo $sql;
			echo "<br />";
		}
}

echo "ende<br>";

?>