Faster way for this mysql_query
$handle = fopen("stock.csv", "r");
while (($data = fgetcsv($handle, 1000, ";")) !== false) {
$model = mysql_real_escape_string ($data[0]);
$quantity = mysql_real_escape_string ($data[7]);
mysql_select_db("verradt33_xoho", $link);
$quantity = str_replace("JA", "10", $quantity);
$quantity = str_replace("NEE", "0", $quantity);
$result = mysql_query("UPDATE dev_product
SET quantity = $quantity
WHERE model = '$model'")
or die(mysql_error());
Even tho the code works, it takes a long time to process the 7000+ lines
in the CSV. Due to having to replace JA or NEE with 10 or 0 every single
line.
Is there a way to make this faster? I can't touch the csv file, that's the
hard part of course.
Current load time is 40 minutes.
No comments:
Post a Comment