Php 如何连接两个具有相同字段名的表,并使用CodeIgniter在数组中返回这两个表?

Php 如何连接两个具有相同字段名的表,并使用CodeIgniter在数组中返回这两个表?,php,mysql,codeigniter,codeigniter-3,Php,Mysql,Codeigniter,Codeigniter 3,表格结构如下: public function appProfile($id=null) { $query= $this->db->where('software_db.id',$id) ->from('software_db') ->join('dev_db','software_db.dev_id=dev_db.id','right') -&g

表格结构如下:

public function appProfile($id=null)
{
   $query= $this->db->where('software_db.id',$id)
                    ->from('software_db')
                    ->join('dev_db','software_db.dev_id=dev_db.id','right')
                    ->select(['dev_db.name','dev_db.id','software_db.id','software_db.name','software_db.file_name','software_db.image_name'])
                    ->get()
                    ->result_array();
    print_r($query);die;
}
输出数组从不包含dev_db中的id和名称。它应该返回software\u db中的所有字段,其中software.id=$id以及dev\u db中的name和id。

Try就是这样

dev_db(id(primary key),name,email,password,comany,skills)
software_db(id(primary key), name,file_name,image_name,description,platform,cateogory)
select()
不应该有方括号
[]

在select子句中创建别名,类似于

public function appProfile($id = '') {

    $this->db->select('dev_db.name, dev_db.id, software_db.id, software_db.name, software_db.file_name, software_db.image_name');
    $this->db->from('software_db');
    $this->db->join('dev_db', 'dev_db.id = software_db.dev_id', 'right');
    $this->db->where('software_db.id',$id);
    $query = $this->db->get();

    return $query->result_array();

}

你是不是想加入
software_db.id=dev_db.id
而不是
software_db.dev_id=dev_db.id
select不应该有[]@drfranks3不,先生,它是'software_db.dev_id=dev_db.id'。它只返回dev_db的
名称
字段
->select('dev_db.name as dev_db_name') // etc