gpt4 book ai didi

php - 如何将数据从单个表单插入到 codeigniter 框架中的多个表? - 以下方法无效

转载 作者:太空宇宙 更新时间:2023-11-03 10:54:27 29 4
gpt4 key购买 nike

任何人都知道如何在 codeigniter 中将数据从单个表单插入到多个表中我尝试了以下方法,但它不起作用

模型

function add_models(){

$data1 = array(
'companykeyid' => $this->input->post('ckeyid'),
'name' => $this->input->post('name'),
'age' => $this->input->post('age'),

);
$data2 = array(
'companykeyid' => $this->input->post('ckeyid'),
'phrase' => $this->input->post('phrase'),
'medialength' => $this->input->post('medialength'),
);
$data3 = array(
'companykeyid' => $this->input->post('ckeyid'),
'phrase' => $this->input->post('phrase')
'medialength' => $this->input->post('medialength'),
);
$this->db->insert('girls', $data1);
$this->db->insert('movies',$data2);
$this->db->insert('keywords',$data3);
}

最佳答案

你做的方法是有效的,我认为你的问题是语法错误(data3 数组中缺少逗号)。

所以,这应该可行:

    function add_models(){

$data1 = array(
'companykeyid' => $this->input->post('ckeyid'),
'name' => $this->input->post('name'),
'age' => $this->input->post('age')

);
$data2 = array(
'companykeyid' => $this->input->post('ckeyid'),
'phrase' => $this->input->post('phrase'),
'medialength' => $this->input->post('medialength')
);
$data3 = array(
'companykeyid' => $this->input->post('ckeyid'),
'phrase' => $this->input->post('phrase'),
'medialength' => $this->input->post('medialength')
);
$this->db->insert('girls', $data1);
$this->db->insert('movies',$data2);
$this->db->insert('keywords',$data3);
}

重要 - 你必须确保表中的字段名称是正确的......如果这不起作用,你的问题出在代码的其他地方(检查你的 Controller , View ......)

关于php - 如何将数据从单个表单插入到 codeigniter 框架中的多个表? - 以下方法无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21801179/

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