Hello,
How can i do batch updates in CodeIgniter instead of firing query each and every time in database?
Thanks in advance :)
Hello,
How can i do batch updates in CodeIgniter instead of firing query each and every time in database?
Thanks in advance :)
Mysql can do multiple updates or inserts. Usually in an Active Record pattern you do inserts one by one, but for bulk updates or inserts you can do this.
$sql = "INSERT INTO table (id,Col1,Col2) VALUES (1,1,1),(2,2,3),(3,9,3),(4,10,12) ON DUPLICATE KEY UPDATE Col1=VALUES(Col1),Col2=VALUES(Col2);";
$this->db->query($sql);