Welcome Guest, Not a member yet? Register   Sign In
Using two databases
#5

[eluser]gcanizal[/eluser]
I still have the same problem. If I activate database db2 in file "database.php":

Code:
$active_group = "db2";

On the one hand, I call the next controller and I have a database error:

Code:
class TestDB extends My_Controller
{
    private $db1;


    function TestDB()
    {
        parent::My_Controller();


    }


    function index()
    {

        $response = $this->A();
        $response = $this->B();    


        

    }


    public function A (){
        $this->db1 = $this->load->database('db1',TRUE);
        $result_set = $this->db1->query("SELECT * FROM TABLE1");
    }
    public function B (){
        $this->db->query("SELECT * FROM TABLE2");
    }

    


}

It returns:


A Database Error Occurred

Error Number:

SELECT * SELECT * FROM TABLE2



But if I call the functions in the other order (first I call B and then A), everything goes fine.

Is there any problem with "mssql driver"? We lose the default data base connection.


On the other hand, in the case I reconnect before all querys it works fine:

Code:
class TestDB extends My_Controller
{
    private $db1;


    function TestDB()
    {
        parent::My_Controller();


    }


    function index()
    {

        $response = $this->A();
        $response = $this->B();    


        

    }


    public function A (){
        $this->db1 = $this->load->database('db1',TRUE);
        $result_set = $this->db1->query("SELECT * FROM TABLE1");
    }
    public function B (){
                $db2 = $this->load->database('db2',TRUE);
        $db2->query("SELECT * FROM TABLE2");
    }

    


}

And finally my problem:
What happens with the sessions when they are stored in a table if we lose the default connection?


Thank you


Messages In This Thread
Using two databases - by El Forum - 10-22-2009, 07:07 AM
Using two databases - by El Forum - 10-22-2009, 07:24 AM
Using two databases - by El Forum - 10-22-2009, 09:03 AM
Using two databases - by El Forum - 10-23-2009, 12:24 AM
Using two databases - by El Forum - 11-04-2009, 09:09 AM
Using two databases - by El Forum - 11-04-2009, 09:16 AM
Using two databases - by El Forum - 11-04-2009, 10:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB