php - get the result of select query with different database in codeigniter -
i have declared 2 databases in database.php, how can access users list of db , db2 instances
//database initialisation $ci =& get_instance(); $ci->db1 = $ci->load->database('default', true); $ci->db2 = $ci->load->database('stylior_db', true); //select query db2 $this->$db2->from('users'); // $this->$ci->db2->where('id',1312); $query = $this->$ci->db2->get(); print_r($query); if ( $query->num_rows() > 0 ) { $row = $query->row_array(); return $row; }
try way
$db_result = $this->db->get("table_users"); // here default database connected $this->db1 = $this->load->database('db1', true); $db1_result = $this->db1->get("table_users")
Comments
Post a Comment