Reputation: 51
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;
}
The table structure is as follows:
dev_db(id(primary key),name,email,password,comany,skills)
software_db(id(primary key), name,file_name,image_name,description,platform,cateogory)
The output array never contains the id and name from dev_db. It should return all the fields from software_db where software.id=$id and name and id from dev_db.
Upvotes: 2
Views: 49
Reputation: 7997
select()
shouldn't have square brackets [ ]
.
in your select clause create aliases, something like
->select('dev_db.name as dev_db_name') // etc
Upvotes: 1
Reputation:
Try is this way
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();
}
Upvotes: 1