I have a CodeIgniter/PHP Model and I want to insert some data into the database.
However, I have this set in my \'raw\' SQL query:
ON DUPLICATE KEY U
You can add the "ON DUPLICATE" statement without modifying any core files.
$sql = $this->db->insert_string('table', $data) . ' ON DUPLICATE KEY UPDATE duplicate=LAST_INSERT_ID(duplicate)'; $this->db->query($sql); $id = $this->db->insert_id();
I hope it's gonna help someone.