Welcome Guest, Not a member yet? Register   Sign In
switching database for use with $this->load->dbutil();
#1

[eluser]matt2012[/eluser]
im trying to backup a database but the dbutil seems to use the default group
how do I get it to use another database group.

Code:
$this->load->database($group, TRUE);
$this->load->dbutil();
//$prefs =..
$backup =& $this->dbutil->backup($prefs);

Its working in that im getting a database downloaded but not using $group
rather 'default_group';
#2

[eluser]Randy Casburn[/eluser]
[quote author="matt2012" date="1223500736"]im trying to backup a database but the dbutil seems to use the default group
how do I get it to use another database group.

Code:
$this->load->database($group, TRUE);
$this->load->dbutil();
//$prefs =..
$backup =& $this->dbutil->backup($prefs);

Its working in that im getting a database downloaded but not using $group
rather 'default_group';[/quote]

Right, try...

Code:
$myDbHandle = $this->load->database($group, TRUE);
$this->load->dbutil();
//$prefs =..
$backup =& $this->myDbHandle->dbutil->backup($prefs);

Randy
#3

[eluser]matt2012[/eluser]
Code:
$db1 = $this->load->database($group, TRUE);      
              
$backup =& $this->db1->dbutil->backup($prefs);

I get
Code:
Message: Undefined property: Backup::$db1
#4

[eluser]Randy Casburn[/eluser]
Right...that's because I was wrong. Sorry.

Bad news. I looked at the code for the DB utils class and it reads your database.php default_group setting out of the config file and completely ignores any loaded databases. Therefore, you cannot backup any database that is not currently set as the default_group in the database.php config file.

The relevant code is on line 40 of DB_utils.php which makes reference to $CI->db that is set between lines 32 & 47 of DB.php.

I recommend you create your own work around or recommend a change to the core. They will take this up if it makes a difference to the community.

I will tell you from experience that multiple database issues don't get a lot of visibility. I'm not sure why. Most likely few of us are actually stressing that test I suppose.

Sorry for the bad news.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB