duanca3415 2013-06-20 08:07
浏览 44

如何在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.

  • 写回答

2条回答 默认 最新

  • douqiandai4327 2013-06-20 08:24
    关注

    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'));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端