我有一家公司在那里提供产品提要,其中包含有关库存、价格等的所有详细信息作为 CSV 文件。我使用以下脚本使用该 CSV 文件更新我的数据库:
<?php
echo "Update wordt uitgevoerd.... <br><br>";
$mysqlHost = "localhost";
$user = "username";
$password = "password";
$link = mysql_connect($mysqlHost, $user, $password)
or die('Could not connect: ' . mysql_error());
$handle = fopen("update.csv", "r");
while (($data = fgetcsv($handle, 1000, ";")) !== false) {
$model = mysql_real_escape_string ($data[0]);
$price = mysql_real_escape_string ($data[5]);
$quantity = mysql_real_escape_string ($data[7]);
mysql_select_db("wowtoxco_oc1", $link);
$result = mysql_query(
"UPDATE oc_product SET price='$price', quantity='$quantity'
WHERE model='$model'"
) or die(mysql_error());
echo $model . " - art.nr. locked -> ";
echo $price . " prijs updated -> ";
echo $quantity . " voorraad updated.<br>";
}
fclose($handle);
mysql_close($link);
echo "<br>Script uitgevoerd.";
?>
问题: CSV 文件中的价格为 1.25,而 OpenCart 预计为 1.25。
有没有办法让脚本在查询运行之前用点替换逗号?