Transaction on model function |
Hi , can i use transaction on model function ?
for example : Code: $a=new AModel(); is it correct way ?
No, you should use transactions on each model seperate.
You can look at nested transactions in the CodeIgniter 4 User Guide but I do not think that works with multiple models. Maybe @kenji could chime in on this. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Transactions work on a database connection.
If the two models have the same db connection, the transaction works.
Probably you use only one DB connection.
But CI can have many DB connection (database group) setting. See https://codeigniter4.github.io/CodeIgnit...onfig-file And can have multiple DB connections. See https://codeigniter4.github.io/CodeIgnit...e-database
Hi hi have problem with transaction (same db):
Code: $db = \Config\Database::connect(); I tranfer quantity from one record to another record and set to null several culumns Sometimes it does until : $res_riempimento = $locazioni_piani_model->update($locazione_da_riempire->id,$dati_to_update_riempimento); and before don't set to null the culumn as in this case (as this image) : https://ibb.co/LdXZybh
It's a bug? Why doesnt transaction work properly?
What's the problem?
Your code is difficult to understand. And I don't understand what the screenshot means. Can you show more simple code to reproduce your issue? |
Welcome Guest, Not a member yet? Register Sign In |