我试图创建一个简单的 SQL INSERT 否则 UPDATE 语句,但老实说我不知道我在做什么
到目前为止,这是我的功能
function addInventoryBook($isbn, $sku, $price, $quantity, $condition, $dateOpened){
$q = "INSERT INTO ".TBL_INVENTORY." VALUES('$isbn', '$sku', $price,
$quantity, '$condition', $dateOpened)
ON DUPLICATE KEY UPDATE VALUES('$isbn', '$sku', $price, $quantity,
'$condition', $dateOpened)";
return mysql_query($q, $this->connection);
}
似乎更新价格字段的先前功能正在工作
function addInventoryBook($isbn, $sku, $price, $quantity, $condition, $dateOpened){
$q = "INSERT INTO ".TBL_INVENTORY." VALUES('$isbn', '$sku', $price,
$quantity, '$condition', $dateOpened)
ON DUPLICATE KEY UPDATE price = $price";
return mysql_query($q, $this->connection);
}