Hi,
I'm busy with a project in cakePHP where I need to parse a couple of XML files and insert the relevant data in my mysql database. The script inserts what it should insert, that's not the problem. For example if I parse one or 2 files (approx 7000-8000 records), nothing goes wrong.
Problems start when I parse the third or fourth xml file. After a minute inserting records I see there are 9000-10000 records succesfully inserted in the database, but suddenly it seems the script restarts itself. I notice 0 records are present in the table and it restarts inserting all the records. So the script is just taking ages to execute.
Short snippet:
$content = simplexml_load_file($file);
/**
* Process line per line
*/
foreach ($content->product as $line) {
// create new record in products database table
$product = array();
$product['Product']['productid'] = $line->attributes()->sku_number;
$product['Product']['name'] = $line->attributes()->name;
$product['Product']['description'] = empty($line->description->long) ? $line->description->short : $line->description->long;
$product['Product']['link'] = $line->URL->product;
$product['Product']['affiliate'] = 'linkshare';
$product['Product']['price'] = $line->price->retail;
$product['Product']['brand'] = strtolower($line->brand);
$product['Product']['image'] = $line->URL->productImage;
// if not in rejectedproducts, save the new product to the database
if (!$rejectedproductModel->findByProductid($product['Product']['productid'])) {
$productModel->create();
$productModel->save($product);
}
Somebody got experience with this? What could be the cause and more what could be a solution :)
Thanks