问题
如何在 Codeigniter 中一次更新 3 个表?我早些时候这样做了,但这种情况有点不同,我现在被困了两天。
我有 3 个要更新的表。
我不知道如何使用连接表更新 3 个表。我的模型如下所示:
function edit_aanbieding($data, $image_data)
{
$id = $this->uri->segment(3);
$this->db->update('Aanbiedingen', $data);
$insertfoto = array(
'fotonaam' => $image_data['file_name']
);
$this->db->join('Aanbiedingen', 'bedrijfaanbiedingen.idaanbiedingen = Aanbiedignen.idaanbiedingen');
$this->db->join('fotoaanbiedingen', 'bedrijfaanbiedingen.idfotoaanbiedingen = fotoaanbiedingen.idfotoaanbiedingen');
$this->db->where('idbedrijfaanbiedingen', $id);
$this->db->update('fotoaanbiedingen', $insertfoto);
}
我的控制器如下所示:
function editaanbieding()
{
$data = array(
'Aanbieding' => $this->input->post('aanbiedingnaam'),
'Tekst' => $this->input->post('aanbiedingomschrijving'),
'Prijs' => $this->input->post('aanbiedingprijs'),
'Conditie' => $this->input->post('aanbiedingconditie')
);
$config['upload_path'] = './assets/uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '';
$config['max_height'] = '';
$config['overwrite'] = TRUE;
$config['remove_spaces'] = TRUE;
$config['file_name'] = $this->input->post('aanbiedingfoto');
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('aanbiedingfoto'))
{
$error = array('error' => $this->upload->display_errors());
}else{
$image_data = $this->upload->data();
}
$this->aanbieding_model->edit_aanbieding($data, $image_data);
redirect('members/aanbiedingen');
}
但这不起作用。希望这对我正在努力实现的目标有意义。