我想在此功能中设置ON DUPLICATE KEY UPDATE。
我怎么能做到这一点?
public function insert($table, $values) {
try {
foreach ($values as $key => $value)
$field_names[] = $key . ' = :' . $key;
$sql = "INSERT INTO " . $table . " SET " . implode(', ', $field_names);
$stmt = self::$PDO->prepare($sql);
foreach ($values as $key => $value)
$stmt->bindValue(':' . $key, $value);
$stmt->execute();
} catch (PDOException $exception) {
die($exception->getMessage());
}
}
有人能帮助我吗?
由于