Welcome Guest, Not a member yet? Register   Sign In
How to run Transactions in controller?
#4

Add this to your BaseController in the "Preload" section of the initController method:

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

You should then be able to use transactions in any Controller like this:

PHP Code:
$this->db->transStart(); //Begin database transaction
$this->db->transComplete(); //Complete database transaction 
Reply


Messages In This Thread
RE: How to run Transactions in controller? - by mlurie - 04-06-2021, 09:44 AM



Theme © iAndrew 2016 - Forum software by © MyBB