从result_array()中提取其类型的值

时间:2017-01-25 00:02:29

标签: php arrays codeigniter

我希望能够从result_array()查询中获取值以在另一个查询中使用。

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class RequestCheckIssueAddressAddressLine {

    private adrLn addrLineTypCdField;

    private bool addrLineTypCdFieldSpecified;

    /// <remarks/>
    [System.Xml.Serialization.XmlAttributeAttribute()]
    public adrLn AddrLineTypCd {
        get {
            return this.addrLineTypCdField;
        }
        set {
            this.addrLineTypCdField = value;
        }
    }

    /// <remarks/>
    [System.Xml.Serialization.XmlIgnoreAttribute()]
    public bool AddrLineTypCdSpecified {
        get {
            return this.addrLineTypCdFieldSpecified;
        }
        set {
            this.addrLineTypCdFieldSpecified = value;
        }
    }
}

我希望能够遍历数组中的每个项目并返回要在where子句中使用的值(例如10,11,12)。

Array ( [0] => Array ( [taskID] => 10 ) [1] => Array ( [taskID] => 11 ) [2] => Array ( [taskID] => 12 ) ) 是数组,$task是数组中的项目。

$t

错误:

  

错误号码:1054

     

未知列&#39;数组&#39;在&#39; where子句&#39;

     

SELECT foreach($task as $t){ $this->db->select('roleID'); $this->db->from('project_tasks'); $this->db->where('taskID', $t); //ERROR line 287 } FROM roleID WHERE project_roles = taskID

     

文件名:models / Project_model.php

     

行号:287

2 个答案:

答案 0 :(得分:2)

foreach($task as $t){
    $this->db->select('roleID');
    $this->db->from('project_tasks');
    $this->db->where('taskID', $t['taskID']);
}

答案 1 :(得分:1)

您忘记了$task是一个数组数组:

foreach($task as $t){
    $this->db->select('roleID');
    $this->db->from('project_tasks');
    $this->db->where('taskID', $t['taskID']); 
}
相关问题