multiple there a way to unload?

Okay, I've tried this two ways, the first way:

//load DB1
$query = $this->db->query('SELECT * FROM user WHERE id = '.$id);

//insert DB2
$sql = "INSERT INTO comments blah blah blah";
will always try to insert the "comments" db into secret instead of notsecret...

But if I do as the manual says when setting up two dbs:

//load two databases
$secretDB = $this->load->database('secret', TRUE);
$notsecretDB = $this->load->database('notsecret', TRUE);

$query = $secretDB->query('SELECT * FROM user WHERE id = '.$id);
$sql = "INSERT INTO comments blah blah blah";

It tries to query the user from notsecret instead of secret. Notsecret is the default in the database config.

Is there a way to unload the db in between or am I missing a command?

Thanks for your time! I appreciate your help.

I've seen two other posts with this same problem and neither of them had a reply. Is this a bug?

Okay, so I found this other message, which is a little more helpful and still vague so I'm going to explain how I've found that it works through pure trial and error. It ONLY works this way for me for whatever reason. Loading the databases together always defaults to the last loaded database, essentially "unloading" the previous database making the multiple database accessibility useless.

//load first database
$this->secretDB = $this->load->database(’secret’, TRUE);

$query = $secretDB->query(’SELECT * FROM user WHERE id = ‘.$id);

//load second database
$this->notsecretDB = $this->load->database(’notsecret’, TRUE);

$sql = “INSERT INTO comments (comment_column) VALUES (".$this->notsecretDB->escape($comment_column).")”;


I found this message
which clued me into the
$this->actualdbvar = $this->load->database(’dbnameindatabaseconfig’, TRUE);
which is NOT in the documentation. I also found out that you must use
and not
as shown on the documentation here:

If you use the suggested $this->db->escape it will give you a blank page with no error.

As far as I can tell, there is no unloading mechanism, just loading in sequence, and no "preloading" for later use which is a major pain.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.