Welcome Guest, Not a member yet? Register   Sign In
multiple db problem
#1

[eluser]Steerlin[/eluser]
Hi,

I'm using CI to develop a DB migration tool for a client. I've managed to connect to an Access and Postgres DB simultaneously but run into trouble when the querying starts. It appears as if the two connections share an odbc object:

Code:
class Test extends Controller {

    function Test()
    {
        parent::Controller();    
    }
    
    function index()
    {
        echo "connect to Access DB\n";        
        $msaccess    = $this->load->database('msaccess', TRUE);
        echo "connect to Postgres DB\n";
        $postgres    = $this->load->database('postgres', TRUE);
        
        $msaccess->limit(1);
        $editorial    = $msaccess->get('tablename');
        foreach($editorial->result() as $row)
        {
            echo $row->Id." ";
        }    
    }
}


This works fine if I put the $postgres statement after the foreach loop or when I comment it out. But loading and using the two db's simultaneously (code exactly as above) crashes:

Severity: WarningMessage: odbc_errormsg(): 27 is not a valid ODBC-Link resource
Filename: odbc/odbc_driver.phpLine Number: 320
A PHP Error was encountered

Severity: WarningMessage: odbc_error(): 27 is not a valid ODBC-Link resourceFil
ename: odbc/odbc_driver.phpLine Number: 333
A PHP Error was encountered

Severity: WarningMessage: odbc_errormsg(): 27 is not a valid ODBC-Link resource
Filename: odbc/odbc_driver.phpLine Number: 320
Database Error

Could this be a bug ?

to clarify:

this works:

Code:
$msaccess    = $this->load->database('msaccess', TRUE);
$res    = $msaccess->get('picture')->result();
print_r($res);
            
$postgres    = $this->load->database('postgres', TRUE);            
$res    = $postgres->get('poi')->result();
print_r($res);

this doesn't work:

Code:
$msaccess    = $this->load->database('msaccess', TRUE);
$postgres    = $this->load->database('postgres', TRUE);

$res    = $msaccess->get('picture')->result();
print_r($res);        
                
$res    = $postgres->get('poi')->result();
print_r($res);




Theme © iAndrew 2016 - Forum software by © MyBB