Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14346

CI 3.1.0 multi delete and update, is a bug?

$
0
0
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

Viewing all articles
Browse latest Browse all 14346

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>