INSERT INTO `dance_payment` (`customer_id`, `firstname`, `date_of_joining`, `month_of_payment`, `amount`, `receipt_number`) VALUES (NULL, 'David Noronha', '2015-08-07', 'august', '1000', 'pan001')
这是" php"代码
if ($this->form_validation->run() == TRUE) {
$data = $this->payment_m->array_from_post(array('customer_id','firstname','date_of_joining','month_of_payment','amount','receipt_number') );
// $data['date_of_joining']=date_format($data['date_of_joining'],"Y-m-d");
$data['date_of_joining'] = flip_date($data['date_of_joining'],'SHOW');
$nid = $this->payment_m->save($data);
//add customer reminder
$this->load->model('customer_course_m');
$selected_course = $this->input->post('courses');
$this->db->delete('dance_customer_course', array('customer_id' => $nid ) );
//insert festival
if(is_array($selected_course) && count($selected_course) > 0)
{
foreach ($selected_course as $kf => $vf)
{
$course_data['customer_id'] = $nid;
$course_data['festival_id'] = $vf;
$this->customer_course_m->save($course_data);
}
}
//end of customer reminder
if($id)
$this->session->set_flashdata('success','Payment details added successfully.');
redirect('customer');
}
这是codeigniter中的代码,有人可以告诉我我做错了什么或者我应该在哪里检查这个错误的原因,我在codeigniter真的很糟糕,帮助会非常感激。过去两天一直困扰着我,谢谢:)。
答案 0 :(得分:0)
Error 1048 Column 'customer_id' cannot be null”
由于以下原因显示
如果您希望customer_id传递为Null,则将其设置为自动递增(如果customer_id是主键,则为其良好选项)
当您调用以下模型时(如果您共享模型代码也更好)
$nid = $this->payment_m->save($data);
检查你在$ nid中获得的价值。