gpt4 book ai didi

php - 如何使用 codeigniter 将选项值插入数据库

转载 作者:行者123 更新时间:2023-11-29 20:56:02 25 4
gpt4 key购买 nike

我需要使用此选项 View 将我的选项值插入数据库:

<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>

这是我所做的 Controller :

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,我应该在 Controller 和模型中做什么?

提交后我收到以下错误:

A Database Error Occurred

Error Number: 1054

Unknown column 'restaurant_info' in 'field list'

UPDATE uhd_restaurant SET restaurant_info = NULL, restaurant_busy = NULL WHERE restaurant_id = '250'

Filename: C:/Data_web/food.km/application/models/VENDOR/SG/Vendor_m.php

Line Number: 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")
);

关于php - 如何使用 codeigniter 将选项值插入数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37626037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com