【发布时间】:2018-01-11 09:13:10
【问题描述】:
我正在尝试使用codeigniter 在数据库中插入array。但是我遇到了类似的错误
错误号:1064
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 '0, 1, 2, 3) VALUES ('5', '6', '11', '13')' 附近使用正确的语法
插入
customer_orders(0、1、2、3)值('5'、'6'、'11'、'13')文件名:C:/xampp/htdocs/hari/billing-system/system/database/DB_driver.php
行号:691
控制器:
class Customer_order extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->library('form_validation');
$this->load->model('orders');
}
function addnewcustomerorder()
{
$product_id = $this->input->post('product_id');
$data = array(
'product_id' => $product_id
);
//print_r($data);
$res = $this->orders->addnewcustomerorder($data);
}
型号:
function addnewcustomerorder($data)
{
if($data['product_id']!="")
{
foreach($data as $a)
{
$res=$this->db->insert('customer_orders',$a);
return $this->db->insert_id();
}
}
else
{
return false;
}
}
注意:忽略
customer_id
我如何insert 数据库中的值
【问题讨论】:
标签: arrays codeigniter insert