Welcome Guest, Not a member yet? Register   Sign In
Problem with multiple databases and DMZ
#1

[eluser]mrtavo[/eluser]
First of all, hello everyone Smile and please forgive my bad english.

I have a little problem with the feature of connection to multiple databases .

I don't know if the following is the correct behaviour of this feature; when I do a connection with
Code:
$db1= $this->load->database('db1', TRUE);
it seems to change the default database connection.

This is a problem for me, because I'm using the Overzealous Datamapper plugin (DMZ); that uses the default database controller to make every query, and I need to connect to more than one database without DMZ plugin, in the same function of the model.

I'm using DMZ for the main DB that is huge, and I'm owner of that DB. But I need to make access to other DBs where I only have reading permissions, so I can't change the structure to fit with DMZ needs.

So... when I use
Code:
$this->load->database('db1', TRUE);
I can't use DMZ with the default database at the same time. I need to load again the default config for that database.
Code:
$my = $this->load->database('maindb', TRUE);

Why do the function change the default database connection when you turn the second parameter to TRUE in load->database ??
It's supposed you are going to use that object to access that db but what happens if I need to use the default one at the same time?.
Why do I need to load my default database in a variable to reload the default database object?

If I do the following I get an error message too:

Code:
$db1 = $this->load->database('db1', TRUE);
$my = $this->load->database('dbl', TRUE);
$result = $db1->get_where('A', array('Aa like'=>'something%'));

It tells me that my "A" table on db1 doesn't exist, but it does. So I suppose it lost the connection someway.

Thanks for reading.




Theme © iAndrew 2016 - Forum software by © MyBB