I am working on transaction , and in mentioned code I faced some problem. I didn't commit the transaction , but it inserted data into my database.
$this->db->trans_begin();
$this->db->insert('tblorder',$data);
$orderid=$this->db->insert_id();
foreach ($orderItemList as $orderItemList) {
$orderitem = array('orderid' =>$orderid ,'productid' =>$orderItemList->productid ,'amount' =>$orderItemList->amount);
$this->db->insert('tblorderitem',$orderitem);
}
$this->db->trans_complete();
if ($this->db->trans_status() == 1) {
$this->db->trans_rollback();
return "true";
} else {
$this->db->trans_commit();
return "false";
}
I rolled back transaction , and again all data was inserted in my database. What must be the problem? I can't get it.