Welcome Guest, Not a member yet? Register   Sign In
Multiple Databases - Where can I store config data from database for application use?
#5

[eluser]Nick Woodhead[/eluser]
Sorry after re-reading your post and my reply I realized it probably didn't really help you so heres a second attempt lol.

Create a model and autoload it in config/autoload.php :

class dynamic_db extends CI_Model {

public $db;

function __construct()
{
parent::__construct();
}

public function load_db($database_details) {
$this->db = $this->load->database($database_details, TRUE);
}
}


In your user model get the dynamic config settings:


class User_model extends CI_Model {
private $db_user;

public function __construct() {
$this->db_user = $this->load->database(‘user’, TRUE);
}

public function login() {
//validate your login and get dynamic db credentials
$user_query = $this->db_user->query($user_sql); //get info from user DB

$this->dynamic_db->load_db($database_details);
}
}

you should then be able to use this in any model for the dynamic db:

$this->dynamic_db->db->query($sql);


Messages In This Thread
Multiple Databases - Where can I store config data from database for application use? - by El Forum - 12-28-2012, 08:34 AM



Theme © iAndrew 2016 - Forum software by © MyBB