更新数据库字段错误CodeIgniter [英] Update Database Field Error CodeIgniter
本文介绍了更新数据库字段错误CodeIgniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在CodeIgniter 2.1中收到以下错误消息:
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.
这是我在我的模型:
function update2($data){
$this->db->update_batch('users',$data, "id");
}
这是我在我的控制器:
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";
}
推荐答案
/ p>
try this hope its work
function update2($data){
foreach($data as $string_val){
$this->db->update_batch('users',$string_val, "id");
}
}
或
function update2($data){
foreach($data as $string_val){
$this->db->update_batch('users',$string_val->first_name, "id");
}
}
这篇关于更新数据库字段错误CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文