【发布时间】:2017-03-04 09:05:40
【问题描述】:
这是我用来更新我使用 update_batch 函数但它不能正常工作的所有行的代码
public function edit_project_involved($users)
{
foreach ($users as $v_user) {
$data=array('involved'=>1);
$v=$this->db->where('user_id',$v_user);
$query=$this->db->update_batch('tbl_users',$data,$v);
}
if($query)
{
return true;
}
}
我的 $users var_dump 看起来像这样
C:\wamp64\www\spectra\application\models\Project_model.php:536:
array (size=3)
0 => string '40' (length=2)
1 => string '42' (length=2)
2 => string '37' (length=2)
遇到这样的错误
One or more rows submitted for batch updating is missing the specified index.
文件名:C:/wamp64/www/spectra/system/database/DB_query_builder.php
行号:2010
我的桌子是这样的
user_id username involved
1 admin 0
36 siraj 0
37 faizal 0
38 nesru 0
40 jaseer 0
42 maltu 0
43 shahul 0
44 samsheera 0
var_dump($data) 看起来像这样
C:\wamp64\www\spectra\application\models\Project_model.php:544:
array (size=3)
0 =>
array (size=2)
'user_id' => string '40' (length=2)
'involved' => int 1
1 =>
array (size=2)
'user_id' => string '42' (length=2)
'involved' => int 1
2 =>
array (size=2)
'user_id' => string '37' (length=2)
'involved' => int 1
【问题讨论】:
-
定义不能正常工作
-
@manulaiko 现在你还需要什么
-
请帮我解决
-
是代码问题还是codeigniter错误
标签: php codeigniter updates