我需要使用以下选项视图将我的选项值插入数据库:
<label>Add Time</label>:
<select id="dropdownHolder" name="restaurant_busy">
<option value="1">30 minute</option>
<option value="2">1 hour</option>
<option value="3">1 hour 30minute</option>
<option value="4">2 hour</option>
</select>
这是我所做的控制器:
function change_restaurant(){
if(!isset($_COOKIE["vendor_login"])){ redirect("/VENDOR",'refresh'); }
if(!$this->Token_m->m_check_token($this->input->cookie('vendor_login'),$this->input->cookie('vendor_token'))){
setcookie('vendor_login', '', time() - 3600, '/');
redirect('/VENDOR/',"refresh");
}
if ($this->input->cookie('vendor_login') != null) {
$admin_name = $this->input->cookie('vendor_login');
setcookie('vendor_login', $admin_name, time() + 28800, '/');
$msg = $this->input->cookie('vendor_token');
setcookie('vendor_token', $msg, time() + 28800, '/');
}
if($vendorname = $_COOKIE["vendor_login"]) {
$check_login = $this->Vendor_m->m_get_user_by_vendor($vendorname);
$restaurant_id = $check_login["restaurant_id"];
{
if ($_POST = NULL){
redirect("/VENDOR/Vendor/restaurant_setting","refresh");
}
$data = array(
"restaurant_info"=>$this->input->post("restaurant_info"),
'restaurant_busy' => $this->input->post("restaurant_busy")
);
$this->Vendor_m->m_update_restaurant_info( $data,$restaurant_id);
$this->db->last_query();
}
}redirect("/VENDOR/Vendor/restaurant_setting","refresh");
}
这个模型:
function m_update_restaurant_info($restaurant_info, $restaurant_id)
{
$this->db->where("restaurant_id", $restaurant_id);
$this->db->update("uhd_restaurant", $restaurant_info);
}
它是我的选择值,在我的数据库中有一个表名“ uhd_restaurant”,字段为“ restaurant_busy”,在restaurant_busy中有一些注释,例如:0 =不忙(默认),1 = 30分钟,2 = 1小时,3 = 1小时30分钟,4 = 2小时。
如果我选择30分钟,则restaurant_busy中的值必须为1,在控制器和模型中我应该怎么做?
在我提交它之后,出现以下错误:
发生数据库错误
错误编号:1054
“字段列表”中的未知列“ restaurant_info”
UPDATE
uhd_restaurant
SETrestaurant_info
= NULL,restaurant_busy
= NULL WHERErestaurant_id
='250'文件名:C:/Data_web/food.km/application/models/VENDOR/SG/Vendor_m.php
行号:554
尝试使用单引号。我认为下一行
$data = array(
"restaurant_info"=>$this->input->post("restaurant_info"),
'restaurant_busy' => $this->input->post("restaurant_busy")
);
应该
$data = array(
'restaurant_info' =>$this->input->post("restaurant_info"),
'restaurant_busy' => $this->input->post("restaurant_busy")
);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句