Welcome Guest, Not a member yet? Register   Sign In
How to reference the value of a result in a second query
#3

(12-12-2015, 04:04 PM)solidcodes Wrote: You can use one to many relationship, so the table must look like this below,

Code:
       
Organization
-------------------------------------
org_id | person_id | more columsn here ....      
-------------------------------------
       
People
-------------------------------------
person_id | more columsn here ....      
-------------------------------------  
       
       
The Query
Code:
       
   function get_record_by_id($person_id)
   {
           $q = $this->db->select('org_id, person_id, organization')
                            ->from('organization')
                            ->where('person_id', $person_id)
                            ->limit(1)
                            ->get();

           if($q->num_rows() > 0) {
                   foreach ($q->result() as $row) {
                           //$data[] = $row;
                           $data = $row->organization;
                   }

                   return $data;
           }
   }
       
       
Not tested buy try...

thank you very much for your help.. sorry it took so long to get back here but life happens.. again thanks much
Reply


Messages In This Thread
RE: How to reference the value of a result in a second query - by HMiles - 12-29-2015, 04:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB