on_duplicate_update 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
class MY_DB_mysqli_driver extends CI_DB_mysqli_driver | |
{ | |
final public function __construct($params) | |
{ | |
parent::__construct($params); | |
} | |
function _insert_on_duplicate_update($table, $update, $values) | |
{ | |
foreach($values as $key=>$value) | |
{ | |
$insert_fields[] = $key.'='.$value; | |
} | |
foreach($update as $key=>$name) | |
{ | |
$update_fields[] = $name.'='.$values['`'.$name.'`']; | |
} | |
return "INSERT INTO ".$table." SET ".implode(',', $insert_fields)." ON DUPLICATE KEY UPDATE ".implode(',', $update_fields); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment