• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Transaction in controller throwing error

#1
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.