0

I am working on a project which needs to connect with three databases, one in MySQL and the other two in MSSQL. I am using codeigniter as the framework and I can successfully connect to two databases. But when I try to connect to the third MSSQL database using the same method used to connect the second one, all the previous connections are gone. The database config arrays in database.php are correct.

The default configurations are for MySQL

I connected the second db as follows.

$mssql = $this->load->database('mssql1', TRUE);

And the third on as follows

$mssq2 = $this->load->database('mssql2', TRUE);

Thanks in advance

Abin
  • 1,699
  • 1
  • 14
  • 17
  • does it work when you only use 1(MySQL) and 3 (MSSQL)? – Robert Jul 17 '12 at 12:41
  • Yes, actually the two mssql connection is causing the issue. both have the same credentials except the database name. MySQL + One of the mssql connects works fine. But I need to connect these three simultaneously. – Abin Jul 17 '12 at 13:04
  • Which version are you using? I discovered some random bug relating to this and fixed it, but I'll be damned if I can remember where. It might be in 3.0 (develop on GitHub). – Phil Sturgeon Jul 17 '12 at 13:06
  • I am using codeigniter 2.1. SQL server version 5. – Abin Jul 17 '12 at 13:09
  • 1
    Do you have pconnect set to TRUE? – Narf Jul 20 '12 at 09:00

1 Answers1

0

I fixed it by changing the simple_query function in codeigniter DB_driver.php.

function simple_query($sql)
{
    if ( ! $this->conn_id)
    {
        $this->initialize();
    }
    $this->db_select();

    return $this->_execute($sql);
}

added $this->db_select(); to this function. Thanks for all help

Abin
  • 1,699
  • 1
  • 14
  • 17