我有两个表user和treeview.从我的注册表中我想将数据传递给这些表.比如我想通过username对user表和sponsor ID对treeview表.对于单个表我使用以下约定.
public function add_user()
{
$data=array(
'user_name'=>$this->input->post('fullname'),
'sponsor_id'=>$this->input->post('sponsor_id'),
);
$this->db->insert('user',$data);
}
Run Code Online (Sandbox Code Playgroud)
对于多表,我该怎么办?
怎么样:
public function add_user()
{
$data1 = array('user_name' => $this->input->post('fullname'));
$data2 = array('sponsor_id' => $this->input->post('sponsor_id'));
$this->db->insert('user', $data1);
$this->db->insert('treeview', $data2);
}
Run Code Online (Sandbox Code Playgroud)
在将数据插入数据库之前,请不要忘记清理数据.
| 归档时间: |
|
| 查看次数: |
2747 次 |
| 最近记录: |