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(primary key),name,email,password,comany,skills)
software_db(id(primary key), name,file_name,image_name,description,platform,cateogory)
输出数组永远不会包含dev_db中的id和名称。它应该返回software_db中的所有字段,其中software.id = $ id和dev_db中的name和id。
答案 0 :(得分:1)
尝试就是这样
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();
}
答案 1 :(得分:1)
select()
不应该有方括号[ ]
。