Note that there are some explanatory texts on larger screens.

plurals
  1. POserver error executing a large file
    text
    copied!<p>I have created a script which reads an XML file and adds it to the database. I am using XML Reader for this. The problem is that my XML contains 500,000 products in it. This causes my page to time out. is there a way for me to achieve this?</p> <p>My code below:</p> <pre><code>$z = new XMLReader; $z-&gt;open('files/NAGardnersEBook.xml'); $doc = new DOMDocument; # move to the first node while ($z-&gt;read() &amp;&amp; $z-&gt;name !== 'EBook'); # now that we're at the right depth, hop to the next &lt;product/&gt; until the end of the tree while ($z-&gt;name === 'EBook') { $node = simplexml_import_dom($doc-&gt;importNode($z-&gt;expand(), true)); # Get the value of each node $title = mysql_real_escape_string($node-&gt;Title); $Subtitle = mysql_real_escape_string($node-&gt;SubTitle); $ShortDescription = mysql_real_escape_string($node-&gt;ShortDescription); $Publisher = mysql_real_escape_string($node-&gt;Publisher); $Imprint = mysql_real_escape_string($node-&gt;Imprint); # Get attributes $isbn = $z-&gt;getAttribute('EAN'); $contributor = $node-&gt;Contributors; $author = $contributor[0]-&gt;Contributor; $author = mysql_real_escape_string($author); $BicSubjects = $node-&gt;BicSubjects; $Bic = $BicSubjects[0]-&gt;Bic; $bicCode = $Bic[0]['Code']; $formats = $node-&gt;Formats; $type = $formats[0]-&gt;Format; $price = $type[0]['Price']; $ExclusiveRights = $type[0]['ExclusiveRights']; $NotForSale = $type[0]['NotForSale']; $arr[] = "UPDATE onix_d2c_data SET is_gardner='Yes', TitleText = '".$title."', Subtitle = '".$Subtitle."', PersonName='".$author."', ImprintName = '".$Imprint."', PublisherName = '".$Publisher."', Text = '".$ShortDescription."', BICMainSubject = '".$bicCode."', ExcludedTerritory='".$NotForSale."', RightsCountry='".$ExclusiveRights."', PriceAmount='".$price."', custom_category= 'Uncategorised', drm_type='adobe_drm' WHERE id='".$isbn."' "; # go to next &lt;product /&gt; $z-&gt;next('EBook'); $isbns[] = $isbn; } foreach($isbns as $isbn){ $sql = "SELECT * FROM onix_d2c_data WHERE id='".$isbn."'"; $query = mysql_query($sql); $count = mysql_num_rows($query); if($count &gt;0){ } else{ $sql = "INSERT INTO onix_d2c_data (id) VALUES ('".$isbn."')"; $query = mysql_query($sql); } } foreach($arr as $sql){ mysql_query($sql); } </code></pre> <p>Thank you,</p> <p>Julian</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload