Welcome Guest, Not a member yet? Register   Sign In
CI 3.1.0 multi delete and update, is a bug?
#1

In a method I have two queries, the first performs a delete on two tables and everything works well.
After I have a second query to update another table in this way:



PHP Code:
// Delete
$this->db->where('id_pdv', (int)$id)->delete( ['table_1''tabel_2'] );

// Update
$this->db->where('id', (int)$id)->update('pdv'$array_update); 



The update query fails because it inherits the where clause of the delete query like this:

…WHERE id_pdv = 123 AND id = 123

This only happens if the delete query receives multiple tables.


To get the expected result is necessary:

1) Run two separate delete

or

2) Use the delete this way:

PHP Code:
$this->db->delete( ['table_1','table_2'], ['id_pdv' => (int)$id] ); 

or

3) Perform

PHP Code:
$this->db->reset_query(); 

before the update


I'm wrong, or is it a bug?

Thanks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB