I'm building an import application that takes the lines of a txt file and does the update in two tables, it works normally, but the files usually have more than 5 thousand lines, and I'm not able to do the update of all tables with my current method. How could I optimize this code?
foreach($file as $line):
$row = explode(';', $line);
$prodcode = $row[0];
$prodcurrentinv = $row[3];
$prodprice = number_format(intval($row[5]), 2, '.', '') . '00';
$prodretailprice = $prodprice;
$query = $pdo->prepare('UPDATE isc_products SET prodcurrentinv = :prodcurrentinv, prodretailprice = :prodretailprice, prodprice = :prodprice WHERE prodcode = :prodcode LIMIT 1');
$query->bindParam(':prodcurrentinv', $prodcurrentinv, PDO::PARAM_STR, 11);
$query->bindParam(':prodretailprice', $prodretailprice, PDO::PARAM_STR, 11);
$query->bindParam(':prodprice', $prodprice, PDO::PARAM_STR, 11);
$query->bindParam(':prodcode', $prodcode, PDO::PARAM_STR, 12);
$query->execute();
$query = $pdo->prepare('UPDATE isc_product_variation_combinations SET vcstock = :vcstock WHERE vcsku = :vcsku LIMIT 1');
$query->bindParam(':vcstock', $prodcurrentinv, PDO::PARAM_STR, 11);
$query->bindParam(':vcsku', $prodcode, PDO::PARAM_STR, 12);
$query->execute();
endforeach;