Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14348

switching databases

$
0
0
Hi all,

I am trying to use / change the database for different organizations / users. In master database, I have db_name for different organizations, I am using  the following code to store the db_name in session.


Code:
$condition = "subdomain =" . "'" . $data['subdomain'] . "' AND " . "status =1";

$this->db->select('id, db_name');
$this->db->from('sublogin');
$this->db->where($condition);
$this->db->limit(1);

$db_name = $this->db->get()->row()->db_name;

// SET db_name for session
$this->session->set_userdata('db_name', $db_name);

in another model, switch the database 


PHP Code:
$db_name $this->session->userdata('db_name');

$this->db->db_select($db_name); 

Its working in localhost but not on my live server.
Whats wrong here?

Viewing all articles
Browse latest Browse all 14348

Trending Articles