Update Database Field Error CodeIgniter

codeigniter, codeigniter-2, mysql, php

Solution

try this hope its work

function update2($data){
   foreach($data as $string_val){
   $this->db->update_batch('users',$string_val, "id");
    }
}

or

function update2($data){
   foreach($data as $string_val){
   $this->db->update_batch('users',$string_val->first_name, "id");
    }
}

Problem

I am getting the following error message in CodeIgniter 2.1: ``` A PHP Error was encountered Severity: Notice Message: Array to string conversion Filename: database/DB_active_rec.php Line Number: 1407 ``` I'm trying to update fields in my database. I have this code and every tutorial are just the same for batch upload. It works anyway but the thing is it display such an error. this what i have in my model: ``` function update2($data){ $this->db->update_batch('users',$data, "id"); } ``` This what i have in my controller: ``` public function updateValues(){ $this->load->model('get_db'); $newRow = array( array( 'id' => '3', 'firstname' => 'Rapphie' ), array( 'id' => '2', 'firstname' => 'Charmie' ) ); $this->get_db->update2($newRow); echo "it has been updated"; } ```

Original source