Welcome Guest, Not a member yet? Register   Sign In
Transaction in controller throwing error
#1

(This post was last modified: 07-08-2020, 10:13 AM by @nuj_3313.)

Hi all,

I want to use transaction in the controller but I am getting below error:
Undefined property: App\Controllers\Product_Control::$db (Product_Control is my controller)

My code is as below

Code:
$this->db->transBegin();
if($result === false)
{
     $this->db->transRollback();
     return false;
}

Am I doing anything wrong here.?... Please help me.
Reply
#2

You need to connect to the database:
https://codeigniter.com/user_guide/datab...cting.html

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




Theme © iAndrew 2016 - Forum software by © MyBB