简体   繁体   English

从存储查询php的结果的数组var中获取值单值

[英]get value single value from array var that stores result of query php

I have a query that stores result of query like 我有一个查询存储查询的结果,如

$this->load->model('person/person_model');
$data['result'] = $this->person_model->get('tbl_person', array('id_person' => $some_key),TRUE);

this will return all the fields of person with $some_key (id,name,email...) Then I need to pass $data but before I would like to use name and email of that result 这将返回$some_key (id,name,email ...)的人的所有字段然后我需要传递$ data但在此之前我想使用该结果的名称和电子邮件

so 所以

$this->load->model('person/other_person_job_model');
$status= $this->other_person_job_model->get('tbl_other_person',array('name'=> ?  ),TRUE);

Then I could use $status['name'] or $status['email'] What should I put instead of ? 然后我可以使用$status['name']$status['email']我应该用什么而不是 in the example above? 在上面的例子中? Should I use $data['result']['name'] or something like that? 我应该使用$data['result']['name']或类似的东西? the get function is: get函数是:

function get($table,$where=array(),$single=FALSE) {
        $q = $this->db->get_where($table,$where);
        $result = $q->result_array();
        if($single) {
            return $result[0];
        }
        return $result;
    }

you could use variable, like: 你可以使用变量,如:

$this->load->model('person/person_model');
$result = $this->person_model->get('tbl_person', array('id_person' => $some_key),TRUE);
$data['name'] = $result->name;
$data['result'] = $result;
//and
$this->load->model('person/other_person_job_model');
$status= $this->other_person_job_model->get('tbl_other_person',array('name'=> $result->name  ),TRUE);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM