我使用codeigniter將數據插入數據庫。但是,在出現此錯誤將數據保存到數據庫時出現問題
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;
}
}
UPDATE
這裏是它不斷給我下面的錯誤
Unknown column 'Array' in 'field list'</p><p>INSERT INTO `profile` (`loginid`, `name`, `email`, `gender`, `birthday`, `profilePhoto`, `date`) VALUES (Array, 'Zafar Khan', '[email protected]', 'male', '20.01.1987', '', '2012/11/19')
Filename: /Applications/XAMPP/xamppfiles/htdocs/membership_system/models/model_register.php</p><p>Line Number: 48
這裏是代碼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" } }
更改'date'數組名稱,然後檢查。 –