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";
}
Just realized that using a foreach like M_A_K suggested actually beats the purpose of using the update_batch function. This is because by using foreach, we're actually doing single update (not batch) for each array elements. This is no different than using the (single) update function in CodeIgniter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With