I am setting my two database like this
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'sql.domain.com',
'username' => 'u_name',
'password' => 'pass',
'database' => 'DB_1',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
$db['User_DB'] = array(
'dsn' => '',
'hostname' => 'sql.domain.com',
'username' => 'u_name',
'password' => 'pass',
'database' => 'DB_2',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I am accessing above databases in controller using below code.
public function index(){
$db_anal = $this->load->database('User_DB', TRUE);
$p_name = $this->input->post('p_name');
$user = $this->session->userdata('E_Id');
$tabs_data['res1'] = $this->db->distinct()->select('p_type')->from('tab_1')->get()->result();
//$paper_name = $data;
$UP_array = array(
'Status' => 'success',
'User_id' => $user,
);
$query1['res1'] = $this->db->select('*')->from('tab_1')->where('p_type',$p_name)->get();
$query1['res2'] = $this->db->select('*')->from('tab_2')->where($UP_array)->get();
$query1['res3'] = $db_anal->select('*')->from('tab_3')->where('User_id',$user)->get();
echo json_encode($query1);
return true;
}
I am getting null value by using above code any one can tell me. Is it problem with second database.
How can I solve this any one can help me.?
I am getting below null in console also am using ajax to get data from codeigniter.
{"res1":{"conn_id":{"affected_rows":null,"client_info":null,"client_version":null,"connect_errno":null,"connect_error":null,"errno":null,"error":null,"error_list":null,"field_count":null,"host_info":null,"info":null,"insert_id":null,"server_info":null,"server_version":null,"stat":null,"sqlstate":null,"protocol_version":null,"thread_id":null,"warning_count":null},"result_id":{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null},"result_array":[],"result_object":[],"custom_result_object":[],"current_row":0,"num_rows":null,"row_data":null},"res2":{"conn_id":{"affected_rows":null,"client_info":null,"client_version":null,"connect_errno":null,"connect_error":null,"errno":null,"error":null,"error_list":null,"field_count":null,"host_info":null,"info":null,"insert_id":null,"server_info":null,"server_version":null,"stat":null,"sqlstate":null,"protocol_version":null,"thread_id":null,"warning_count":null},"result_id":{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null},"result_array":[],"result_object":[],"custom_result_object":[],"current_row":0,"num_rows":null,"row_data":null},"res3":{"conn_id":{"affected_rows":null,"client_info":null,"client_version":null,"connect_errno":null,"connect_error":null,"errno":null,"error":null,"error_list":null,"field_count":null,"host_info":null,"info":null,"insert_id":null,"server_info":null,"server_version":null,"stat":null,"sqlstate":null,"protocol_version":null,"thread_id":null,"warning_count":null},"result_id":{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null},"result_array":[],"result_object":[],"custom_result_object":[],"current_row":0,"num_rows":null,"row_data":null}} teq:863:6
getting everything null any one can help me.?