Welcome Guest, Not a member yet? Register   Sign In
models and db transactions
#3

(03-11-2020, 02:29 PM)zahhar Wrote: Just search documentation for "transactions" and enjoy reading this chapter: https://codeigniter4.github.io/userguide...ransaction

Sorry if I misunderstood something. Can I call an insert from my model from within the start/end? I want to still use the built in insert/update etc. functions from the model.

As an approximate example:
PHP Code:
$myModel = new MyModel;

$myDataHere = [
   
'field1' => 'data',
   
'field2' => 'data'
]

$this->db->transStart();
$myModel->insert($myDataHere);
$this->db->transComplete(); 
Will this work?

Or is there a way I can have the same effect but with the transaction start and end automatically called? So I don't need to specify every time.
Reply


Messages In This Thread
models and db transactions - by kyle - 03-11-2020, 10:48 AM
RE: models and db transactions - by zahhar - 03-11-2020, 02:29 PM
RE: models and db transactions - by kyle - 03-11-2020, 03:13 PM
RE: models and db transactions - by zahhar - 03-12-2020, 01:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB