Search Results

Search found 1 results on 1 pages for 'user1011713'.

Page 1/1 | 1 

  • Multiple/Sub quries with codeigniter

    - by user1011713
    I just started with Codeigniter and this is driving me nuts. I have a query that determines whether a user has bought any programs. I then have to use that program's type category to run and determine how many times he or she has recorded a query in another table. Sorry for the confusion but the code hopefully makes sense. I'm having problem returning the two arrays from my Model to my Controller to onto the view obviously. function specificPrograms() { $specific_sql = $this->db->query("SELECT program,created FROM `assessment` WHERE uid = $this->uid"); if($specific_sql->num_rows() > 0) { foreach ($specific_sql->result() as $specific) { $data[] = $specific; $this->type = $specific->program; } return $data; } $sub_sql = $this->db->query("SELECT id FROM othertable WHERE user_id_fk = $this->uid and type = '$this->type'"); if($sub_sql->num_rows() > 0) { foreach ($sub_sql->result() as $otherp) { $data[] = $otherp; } return $data; } } Then in my Controller I have, $data['specific'] = $this->user_model->specificPrograms(); $data['otherp'] = $this->user_model->specificPrograms(); Thanks for any help.

    Read the article

1