Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iambigd/54142cf97263092829d97726d54d7304 to your computer and use it in GitHub Desktop.
Save iambigd/54142cf97263092829d97726d54d7304 to your computer and use it in GitHub Desktop.
PDO ON DUPLICATE KEY UPDATE for multiple insert rows
function test() {
$sql = "INSERT INTO `table` (`id`, `name`) VALUES (?,?),(?,?) ON DUPLICATE KEY UPDATE `name` = VALUES(`name`) ";
$values = array(1, "test", 2, "so so");
$stmt = $this->db->prepare($sql);
$stmt->execute($values);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment