Hi Community,

I have a question,

I'm using two databases in my project, I connect to one or another depending on the user's session, everything so far so good here, but I have a problem and that's I need transactions, I don't know how to reference the database when I use (BEGIN, COMMIT, ROLLBACK), I'll leave my code for better understanding:

My model is the following:

public function initialize()
    {
        $variable = $this->getDI()->getSession()->get('usu');

        if($variable=="01")
        {
            $this->setConnectionService('db1');
        }elseif($variable=="02"){
            $this->setConnectionService('db2');
        }
    }

In the controller I have the following:

$this->db->begin();

     ......
$this->db->commit();

I don't know how to reference the database that I want,

Thanks in advance,