Php 从结果_数组()中提取其类型的值
我希望能够从result_array()查询中获取值,以便在另一个查询中使用Php 从结果_数组()中提取其类型的值,php,arrays,codeigniter,Php,Arrays,Codeigniter,我希望能够从result_array()查询中获取值,以便在另一个查询中使用 Array ( [0] => Array ( [taskID] => 10 ) [1] => Array ( [taskID] => 11 ) [2] => Array ( [taskID] => 12 ) ) 我希望能够循环遍历数组中的每个项,并返回要在where子句中使用的值(例如10、11、12) $task为数组,$t为数组中的项目 foreach($task
Array (
[0] => Array ( [taskID] => 10 )
[1] => Array ( [taskID] => 11 )
[2] => Array ( [taskID] => 12 )
)
我希望能够循环遍历数组中的每个项,并返回要在where子句中使用的值(例如10、11、12)
$task
为数组,$t
为数组中的项目
foreach($task as $t){
$this->db->select('roleID');
$this->db->from('project_tasks');
$this->db->where('taskID', $t); //ERROR line 287
}
错误:
错误号码:1054
“where子句”中的未知列“Array”
从project\u roles
中选择roleID
,其中taskID
=Array
文件名:models/Project_model.php
电话号码:287
您忘记了
$task
是一个数组:
foreach($task as $t){
$this->db->select('roleID');
$this->db->from('project_tasks');
$this->db->where('taskID', $t['taskID']);
}
这不应该是
$t[0]['taskID']
吗?这会给出所需的行为吗?@Xorifelse否$t
是$task
的一个元素。编辑之后,它会变得更有意义。我原以为数组是来自循环内部的转储。
foreach($task as $t){
$this->db->select('roleID');
$this->db->from('project_tasks');
$this->db->where('taskID', $t['taskID']);
}