我有一个插入查询但有错误:子查询返回超过1行
INSERT INTO `room_rating` (
`date`,
`room_typeid`,
`final_price`,
`commission`,
`room_available`,
`rating_status`,
`hourate_percent_off`,
`num_days_refund`,
`none_refund`,
`cancel_charge_fullcharge`,
`num_night_charge`,
`amendment_date`,
`name_charge`,
`infant_minage`,
`infant_maxage`,
`infant_sh_parent`,
`infant_extrabed`,
`infant_isfreebreak`,
`infant_breakfast_price`,
`child_minage`,
`child_maxage`,
`child_sh_parent`,
`child_extrabed`,
`child_isfreebreak`,
`child_breakfast_price`
)
VALUES
(
'2015-11-09',
'3',
'2.50',
'5',
'6',
'9',
'50',
'',
0,
0,
'',
0,
0,
'0',
'5',
0,
0,
1,
0,
'6',
'11',
0,
0,
1,
0
)
答案 0 :(得分:2)
$arrdate=$this->GetDays($start_date,$to_date);
for ($i=0; $i < count($arrdate); $i++) {
$this->db->where('date',$arrdate[$i])->where('room_typeid',$room_typeid)->where("rating_status <>",'ON')->delete('room_rating');//"DELETE room_rating WHERE date='".$arrdate[$i]."' AND room_typeid='$room_typeid'");
for ($j=0; $j < count($is_hourrate); $j++) {
// echo $is_hourrate[$j];
$data=array(
// 'rating_id'=>$rating_name,
'date'=>$arrdate[$i],
'room_typeid'=>$room_typeid,
'final_price'=>$this->input->post('last_price_'.$is_hourrate[$j]),
'commission'=>$commission,
'room_available'=>$room_available,
'rating_status'=>$is_hourrate[$j],
'hourate_percent_off'=>$this->input->post('price_'.$is_hourrate[$j]),
'num_days_refund'=>$this->input->post('hcancel_duedate'),
'none_refund'=>$none_refund,
'cancel_charge_fullcharge'=>$full_chage,
'num_night_charge'=>$this->input->post('hcancel_charge'),
'amendment_date'=>$this->input->post('hamend_date'),
'name_charge'=>$this->input->post('hname_charge'),
'infant_minage'=>$this->input->post('hrate_infant_minage'),
'infant_maxage'=>$this->input->post('hrate_infant_maxage'),
'infant_sh_parent'=>$rate_infant_sh_parent,
'infant_extrabed'=>$rate_infant_extrabed,
'infant_isfreebreak'=>$rate_infant_isfreebreak,
'infant_breakfast_price'=>$this->input->post('hrate_infant_breakfast_price'),
'child_minage'=>$this->input->post('hrate_child_minage'),
'child_maxage'=>$this->input->post('hrate_child_maxage'),
'child_sh_parent'=>$rate_child_sh_parent,
'child_extrabed'=>$rate_child_extrabed,
'child_isfreebreak'=>$rate_child_isfreebreak,
'child_breakfast_price'=>$this->input->post('hrate_child_breakfast_price')
);
$this->db->insert('room_rating',$data);
}
}