[eluser]LinkFox[/eluser]
[quote author="mvn1990" date="1305342621"]hi, I've got an issue with my query's. first i wanne get id's and to do that i use this query:
$email = $this->session->userdata('email');
$data['id_project'] = $this->db->select('id_project')
->from('tbl_invited')
->join('tbl_user', 'tbl_user.email = tbl_invited.email')
->where('email', $email);
then i wanne use the id's (some times more than one) to get data by using an other query for example:
$data['id_project'] = $this->db->select('name')
->from('tbl_project')
->where('id_project', 'the id's I got from my first query' );
thanks in advance[/quote]
Hi,
You'll need to loop through the results and put them into an array then use the where_in function.
Code:
$this->db->select('id_project')
$this->db->join('tbl_user', 'tbl_user.email = tbl_invited.email')
$this->db->where('email', $email);
$result = $this->db->get('tbl_invited');
// Then loop through the results adding to an array
$projIds = array();
foreach($result as $row) {
array_push($projIds, $row->id_project);
}
// Then finally use the where_in function in your next query
$this->db->select('name');
$this->db->where_in('id_project',$projIds);
$data['id_project'] = $this->db->get('tbl_project');
Although I would guess you could use a join to perform what you need in one query in most cases.