我是codeigniter和使用會話的新手。我在會話中插入單個數據時遇到問題。獲取數據庫中的信息並插入會話codeigniter
型號:
function get_user_info() {
$user_email = $this->input->post('signin-email');
$this->db->select('acct_id, acct_fname, acct_lname, acct_mname');
$this->db->where('email', $user_email);
$query = $this->db->get('account');
return $query->result_array();
}
控制器:
public function LoginValidation(){
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|callback_validate_credentials');
$this->form_validation->set_rules('password', 'Password', 'required|trim|md5');
$this->load->model('users_model');
if($this->form_validation->run()){
$data = array(
'email' => $this->input->post('signin-email'),
'is_logged_in' => 1,
'user_info' => $this->users_model->get_user_info($query->acct_type)
);
$this->session->set_userdata($data);
redirect('home');
}
}
這是行,我希望它放在會議分別:
它總是出現這樣的:
我怎麼能做出這樣的:
[acct_id] => 1
[acct_fname] => Sgt
[acct_lname] => Condoriano
[acct_mname] => T
不清楚你想要什麼? –
而不是在你的模型中使用'result_array()',試着使用'row_array()' – Craig
檢查這行代碼'$ this-> users_model-> get_user_info($ query-> acct_type)'' – Saty