Welcome Guest, Not a member yet? Register   Sign In
Multiple database connexion & session database stored
#1

[eluser]greenju[/eluser]
Hey all,

I have a problem with an application that use both :
- Sessions stored in database
- Multiple databases

I specified a default database (called db1) in which I created the session table. The other databases are also described in the config/database.php file. All the pconnect values are set to false.
The database library is not set in the config/autoload.php but session is.

I need the default database in most of the models, but in some I use a specific one that is loaded in the construct :
Code:
function __construct(){
                parent::__construct();
                $this->load->database('db2');                
        }

But, with this solution when I call method in the model like :
Code:
function liste_item($orderby=null){

                $this->db->select('...');
                $this->db->from('table2');
                ....

I got an error message saying that table2 does not exist in the database 1 (wich is the default one).

I tried to do the following in the construct :
Code:
$db2 = $this->load->database('db2',true)
and then in the method
Code:
$db2->select('...')
...
but I have a message saying the variable $db2 is unknow.

I also tried to set the param sess_use_database to false in the config/config.php file and here it works fine.

Is there a proper way to use both multiple database connection and database session stored?

Thanks.

I'm using CI 2.1.0




Theme © iAndrew 2016 - Forum software by © MyBB