CodeIgniter Forums

Full Version: CI3 Update Multiple Tables
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Did the active record/query builder update functionality decrease from CI2 to CI3? I'm trying to use the query builder to update multiple tables (actually, only updating one table but it joins on another).

For example, something like the below would work in CI2:

$this->db->set('table1.field1', true);
$this->db->where('', 100);
$this->db->update('table1, table2');

Now, in CI3, it seems that the query builder is crapping out in trying to escape the values in the ->update() function. I've tried various input variations for the ->update() function, but it always results in the wrong escape values.

Examples are:
->update('table1, table2') would produce ...`table1,` `table2`...
->update('table1 , table2') would produce ...`table1 ,` `table2`...

Is there a resolution to this? I would hate to have to go through all my CI2 code and rewrite all the functions that update more than one table in the same query.
I don't know which v2 you used where $this->db->update('table1, table2'); worked. The signature of the method is the same in v2.1.4 and v3.1.7 and looks like this.

PHP Code:
public function update($table ''$set NULL$where NULL$limit NULL

The second argument is an associative array of update values in both.

The only reason I can think of that your "update()" syntax worked is that the "DB_active_record" class had been extended with, for example, a "MY_active_record" class that overrides the "update()" method.