我想插入两个不同的值到我的数据库。如何将两个不同的值插入相同的字段?
字段名称是相同的,但我想要保存两个不同的值。
现在我有一个创建组织的窗体。因为我有两个领域的销售和技术。所以我插入姓名,姓氏,销售和技术的电子邮件以及。现在,无论我从哪里获取的值,我都会将其保存到用户表并将其ID保存到我的组织表中。
首先我要插入销售人员的信息,然后技术人员 信息,并得到他们的ID,并将其保存在组织
这是我的代码:
$this->data['company'] = $this->company_m->get_new();
$this->data['user'] = $this->secure_m->get_new();
$rules = $this->company_m->rules_admin;
$this->form_validation->set_rules($rules);
if ($this->form_validation->run() == TRUE)
{
$data =$this->secure_m->array_from_post(array('first_name','last_name','email'));
$sales_id = $this->secure_m->save($data,$id);
$data =$this->secure_m->array_from_post(array('first_name','last_name','email'));
$tech_id = $this->secure_m->save($data,$id);
$data = $this->company_m->array_from_post(array('org_name','dba','addr1','addr2','city','state','country','pin','sales_id','tech_id','tax_number','comment','url'));
$data['sales_id']= $sales_id;
$data['tech_id']= $tech_id;
$this->company_m->save($data, $id);
redirect('admin/company');
}
// Load the view
$this->data['subview'] = 'admin/company/add';
$this->load->view('admin/_layout_main', $this->
从POST数组代码
public function array_from_post($fields){
$data = array();
foreach ($fields as $field) {
$data[$field] = $this->input->post($field);
}
return $data;
}
显示'$ this-> secure_m-> array_from_post'的代码,我认为问题在那里。 – ksimka
@ksimka添加了代码 – Rajan
我真的不明白你的问题是什么。 – Strawberry