Welcome Guest, Not a member yet? Register   Sign In
Struggling with transaction using multiple models
#3

(This post was last modified: 10-09-2020, 01:21 PM by mlurie.)

(10-09-2020, 12:05 PM)InsiteFX Wrote: Your calling them wrong. To run your queries using transactions you will use the

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

and

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

You do not call them using your model.

I tried that originally when I reviewed the documentation, but when I do an Error Exception Undefined property: App\Controllers\Properties::$db occurs.  I am calling it from my controller.

Okay, I realized that I had not loaded the database connection in the BaseController.  I added this to the constructor:

PHP Code:
$this->db = \Config\Database::connect(); 

The Error Exception is now gone, however, the first record is still being inserted when I force the second query to fail.
Reply


Messages In This Thread
RE: Struggling with transaction using multiple models - by mlurie - 10-09-2020, 12:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB