Created
July 3, 2013 19:25
-
-
Save necenzurat/5921918 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
db connection shit loaded here | |
*/ | |
set_time_limit(0); | |
ini_set('memory_limit', '120M'); | |
include "XmlStreamer.php"; | |
class SimpleXmlStreamer extends XmlStreamer { | |
public function processNode($xmlString, $elementName, $nodeIndex) { | |
static $int = 0; | |
$xml = simplexml_load_string($xmlString); | |
//var_dump($xml); | |
$title = mysql_real_escape_string($xml->title); | |
$description = mysql_real_escape_string($xml->description); | |
$link = mysql_real_escape_string($xml->aff_code); | |
$price = $xml->price; | |
$category = mysql_real_escape_string($xml->category); | |
$subcategory = mysql_real_escape_string($xml->subcategory); | |
$images = mysql_real_escape_string($xml->image_urls); | |
$brand = mysql_real_escape_string($xml->brand); | |
mysq_query("INSERT INTO `produse` (`id`, `title`, `description`, `brand`, `category`, `subcategory`, `price`, `images`, `link`, `view`, `click`) | |
VALUES ('', '$title', '$description', '$brand', '$category', '$subcategory', '$price', '$images', '$link', 0, 0);"); | |
$int++; | |
echo chr(13)."importing... [".$int."]"; | |
} | |
} | |
$streamer = new SimpleXmlStreamer("feed2parale.xml"); | |
if ($streamer->parse()) { | |
echo "Finished successfully"; | |
} else { | |
echo "Couldn't find root node"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment