I have a problem when I want to update multiple records with the same query in CodeIgniter.
This is a snippet of my code:
$query = "UPDATE user_data SET name = 'Name1 Surname1' WHERE uid = 'n1s1'; UPDATE user_data SET name = 'Name2 Surname2' WHERE uid = 'n2s2'";
$this->db->query($query);
This returns false so the query does not executes with success.
What can I do to run this query in CodeIgniter?
;. Short answer is - you can't do that. Split that into 2 queries, wrap them with transaction block and that's it.max_allowed_packedsetting in MySQL, that prepared statements lex the query once, send the data through, avoid the parsing of SQL, avoid the possiblemax_allowed_packetand wrapping it in transaction would use 1 I/O to flush it to HDD, making an effective use of hard drive's bandwith. But, hey, we got caught up in this debate if you're a beginner or not. Knowing how to write a query doesn't make anyone an expert. I never called you a beginner btw.