0

Hi there ,
How to write multiple update_batch query in codeigniter?
My script is not working ...
Please give some solutions for multiple update row using update_batch...

getting below Error:

A Database Error Occurred

You must use the "set" method to update an entry.

Filename: D:\xampp\htdocs\DEAL\system\database\DB_active_rec.php

Line Number: 1273

mycontroller :

$this->deal_model->deal_imghighlightupdate($id);    

my model:

Class Deal_model extends CI_Model
{
public function deal_imghighlightupdate($id)
    {

                $dataimages = array();
                if(isset($_FILES["image1"])) {  
                     $this->upload->initialize($config);                    
                         $dataimages[] = array('merchant_deals_id'=>$id, 'deal_images' => $_FILES["image1"]["name"]);                   
                }
                $dataimages = array();
                if(isset($_FILES["image2"])) {  
                     $this->upload->initialize($config);    

                         $dataimages[] = array('merchant_deals_id'=>$id, 'deal_images' => $_FILES["image2"]["name"]);  

                }
                $dataimages = array();
                if(isset($_FILES["image3"])) {  
                     $this->upload->initialize($config);    

                         $dataimages[] = array('merchant_deals_id'=>$id, 'deal_images' => $_FILES["image3"]["name"]);  

                }

        $this->db->update('deal_images', $dataimages, 'merchant_deals_id');
    }
 }

Edited by pritaeas: Moved to PHP.

2
Contributors
2
Replies
12
Views
2 Years
Discussion Span
Last Post by praba_web
0

The third argument for update() must be a WHERE condition (for example: 'id = 4'), instead with update_batch() the third argument is the index key, so try to change your code to:

$this->db->update_batch('deal_images', $dataimages, 'merchant_deals_id');

And it should work.

Edited by cereal

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.