Welcome Guest, Not a member yet? Register   Sign In
Database Config Load Question
#4

[eluser]Craig A Rodway[/eluser]
Ah, okay. A mixture of the two should work then:

Code:
// Get the DB info we need from first DB as set in config/database.php
$sql = 'SELECT * FROM table LIMIT 1';
$query = $this->db->query($sql);
$row = $query->row();

// Create new database configuration array using info from previous SQL query
$config['hostname'] = $row->hostname;
$config['username'] = $row->username;
$config['password'] = $row->password;
$config['database'] = $row->database;
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['active_r'] = TRUE;

// Connect to second database with values from above and assign to new variable
$DB2 = $this->load->database($config, TRUE);


Messages In This Thread
Database Config Load Question - by El Forum - 01-29-2008, 05:32 AM
Database Config Load Question - by El Forum - 01-29-2008, 05:42 AM
Database Config Load Question - by El Forum - 01-29-2008, 10:47 AM
Database Config Load Question - by El Forum - 01-29-2008, 12:03 PM
Database Config Load Question - by El Forum - 03-08-2008, 07:02 PM
Database Config Load Question - by El Forum - 03-14-2008, 02:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB