我正在尝试运行此查询:
protected function store_credentials($config_file_path = 'envato_credentials_config.json') {
$credentials_config = $this->get_envato_config($config_file_path);
$sql = "INSERT INTO credentials (api_key, username, last_update) VALUES (?, ?, NOW()) ON DUPLICATE KEY UPDATE api_key = values(api_key), username = values(username), last_update = values(last_update)";
if ($stmt = $this->connect->prepare($sql)) {
$stmt->bind_param('ss', $credentials_config['API'], $credentials_config['User']);
$stmt->execute();
$stmt->close();
} else {
return false;
}
}
但是发生的情况是,当它执行时我总是得到重复的条目,如果它再次执行,而不是更新它再次运行添加另外两个条目。为什么会这样?