<?php

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

ini_set('display_errors', 1);
error_reporting(E_ALL);	

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

$connection=mysql_connect('localhost', 'int-db-sql-shop', 'Msc7t24?381L') or die ("Verbindungsversuch fehlgeschlagen");
mysql_select_db('webshop-sql', $connection) or die("Konnte die Datenbank nicht waehlen.1");
*/
echo "get items<br>";
// get items
//$sql = 'SELECT * FROM import_items limit 4500,9000';
$sql = "select ii.* from import_items ii
left join items i on i.old_id=ii.pid
where i.id IS NULL";
$query = mysql_query($sql) or die("Anfrage nicht erfolgreich");
$data = array();
while($obj = mysql_fetch_object($query)) {
	$data[] = $obj;
}

echo "imports<br>";
foreach ($data as $object) {

		$sql = "
			INSERT INTO items
			SET
                                old_id='".$object->pid."',
				number='".mysql_real_escape_string($object->produktid)."',
				shippable=1,
				schema_id=3,
				price_type=1,
				seo_keywords='".mysql_real_escape_string($object->keywords)."',
				tax_id=1,
				detail_description='".mysql_real_escape_string($object->beschreibung)."',
				name='".mysql_real_escape_string($object->bezeichnung)."'
		";
		$query = mysql_query($sql);
		if (!$query) {
			echo $sql;
			echo "<br />";
		}
	
	
	
}
echo "ende<br>";


?>