2
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.

3
  • Did you mean to join on software_db.id=dev_db.id rather than software_db.dev_id=dev_db.id Commented Oct 23, 2017 at 22:32
  • select shouldn't have [ ] Commented Oct 23, 2017 at 22:34
  • @drfranks3 no sir, it is 'software_db.dev_id=dev_db.id' Commented Oct 23, 2017 at 22:41

2 Answers 2

1

select() shouldn't have square brackets [ ].

in your select clause create aliases, something like

->select('dev_db.name as dev_db_name') // etc
Sign up to request clarification or add additional context in comments.

Comments

1

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();

}

1 Comment

it is only returning the name field of dev_db

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.