Whith PHP - I write a multi_query something like this:
$MySQL_string .= "UPDATE `table` SET `name` = 'joe' WHERE `ID` = '1'";
$MySQL_string .= "UPDATE `table` SET `name` = 'Jane' WHERE `ID` = '2'";
if($DB->mysqli->multi_query($MySQL_string) === TRUE){
echo"Query executed successfully<BR>";
}else{
echo"Error executing query: ".$DB->mysqli->error;
die();
}
What is the equivalent to PHP's multi_query() in Codeigniter?
If there is no equivilent - how would I use multi_query() in Codeigniter?
Maybe use transactions?
CodeIgniter’s Approach to Transactions
You can use Codeigniter function
$this->db->update_batch()
, to which you can pass either an array or object.To complete your example it could look like this:
and then use:
more info here: