我正在使用 codeigniter 将数据插入数据库。但它一直给我以下错误
Unknown column 'Array' in 'field list'</p><p>INSERT INTO `profile` (`loginid`, `name`, `email`, `gender`, `birthday`, `profilePhoto`, `date`) VALUES (Array, 'Zafar Khan', 'xafar@demo.com', 'male', '20.01.1987', '', '2012/11/19')
Filename: /Applications/XAMPP/xamppfiles/htdocs/membership_system/models/model_register.php</p><p>Line Number: 48
这是发生此错误的代码
public function saveUserProfile() {
$userId = $this->readUserId();
$profile = array(
'loginid' => $userId,
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'gender' => $this->input->post('gender'),
'birthday' => $this->input->post('birthday'),
'profilePhoto' => '',
'date' => date("Y/m/d")
);
$query = $this->db->insert('profile', $profile);
if ($query) {
return true;
} else {
return false;
}
}
更新
这是 readUserId 函数
private function readUserId() {
$this->db->select('id');
$this->db->from('login');
$this->db->where('email', $this->input->post('email'));
return $this->db->get()->result();
}
更新 2
这是我的 var_dump 输出
array(1) { [0]=> object(stdClass)#18 (1) { ["id"]=> string(2) "14" } }