如何在codeigniter中更新3个表?

Question

How do I update 3 tables at once in Codeigniter? I did this earlier but this case is a bit different and I'm stuck for two days now.

I have 3 tables which I want to update.

I don't know how to update 3 tables using a joined table. My model looks like this:

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);
}

My controller looks like this:

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');
}

But this does not work. Hope it makes sense about what I'm tryinc to Achieve.

Can't you just add a hidden field with the photo id in your view? I always do it like this:

form_input(array('name' => 'idfoto', 'type'=>'hidden', 'id' =>'23'));

Instead of making codeigniter do the job, you can make a single update query like this.

UPDATE table1,table2,table3 SET table1.col=a,table2.col2=b,table3.col3=c
WHERE table1.col1=x and table2.col2=y and table3.col3=z;

This would be valid for any number of tables update.