Welcome Guest, Not a member yet? Register   Sign In
Update_batch database error
#1

[eluser]Unknown[/eluser]
Hi all,

I am new to codeigniter, i am using update_batch function of database library and getting the following error:

A PHP Error was encountered
Severity: Notice

Message: Array to string conversion

Filename: database/DB_active_rec.php

Line Number: 1407


Code:
[size=3][color=blue]Below is my code for controller:

function update_values(){

  $this->load->model("get_db");
  
  $newrow=array(
   array(
    "id" => "3",
    "name" => "kamalupdate3"
    ),
    
   array(
    "id" => "4",
    "name" => "kamalupdate4"
    )
  );
  $this->get_db->update2($newrow);
  
  echo 'it is updated';
}


Below is my code for model:

function update2($data){

  $this->db->update_batch("test",$data, "id");
}[/color][/size]

Could anyone plz help me on this?
#2

[eluser]TheFuzzy0ne[/eluser]
It seems you have the right format, but I'm unsure why the method isn't working. The line where the error is throw seems to be:
Code:
$not[] = $k.'-'.$v;

However, $not doesn't seem to be used within that scope. I wouldn't normally advise modifying system files, but in this case, I think you can safely comment that line out. I'll see if I can find the time to test this method out later, and submit a fix for it.
#3

[eluser]TheFuzzy0ne[/eluser]
I finally got around to submitting a bug fix for this, but it turns out that it's already fixed in [url="https://github.com/EllisLab/CodeIgniter/"]CodeIgniter 3[/url], which uses the new Query Builder, and not Active Record.




Theme © iAndrew 2016 - Forum software by © MyBB