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

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.