我的项目中有以下代码:
$start_time = $this->input->post("start_time");
$a = explode(":",$start_time);
$start_sec = ($a[0]*3600)+($a[1]*60);
$end_sec = $start_sec+5400;
$m = ($end_sec/60);
$hrs = (int)($m/60);
$mins = ($m%60);
$sec = "00";
$end_time = $hrs.":".$mins.":".$sec;
$start_time .= ":".$sec;
$tablearr=array(
"rest_id" => $info['rest_id'],
"rest_sec_id" => $info['rest_sec_id'],
"book_date" => $this->input->post("date"),
"book_start_time"=> $this->input->post("start_time"),
"book_end_time" => $end_time,
"book_special" => $this->input->post("purpose"),
"book_cuisine" => $this->input->post("cuisine"),
"book_no_person" => $this->input->post("no_person"),
"user_id" => $this->session->userdata('member_id'),
"book_is_menu" => $this->input->post("menu"),
"table_reserved" => $info['table_reserved']
);
$this->db->insert("b_rest_book",$tablearr);
这应该插入“预订”的单条记录。但是在执行时插入了 5 条记录的查询:一条记录具有所有正确的值,其余 4 条记录具有空值。
开始时间由用户输入,结束时间根据开始时间计算。
插入表格后看起来像这样:
book_id rest_id rest_sec_id book_date book_start_time book_end_time book_special book_cuisine book_no_person user_id book_is_menu table_reserved special_request
1 1 2 2012-12-23 07:00:00 08:30:00 2 2 2 2 No 1
2 1 0 0000-00-00 00:00:00 01:30:00 0 0 0 2 1
3 1 0 0000-00-00 00:00:00 01:30:00 0 0 0 2 1
4 1 0 0000-00-00 00:00:00 01:30:00 0 0 0 2 1
5 1 0 0000-00-00 00:00:00 01:30:00 0 0 0
究竟出了什么问题?