Welcome Guest, Not a member yet? Register   Sign In
Add fields to an active record query result
#1

[eluser]anis2505[/eluser]
Hi,

I have to export some database data to excell sheet.
The data are stored on two DB tables tb1 and tb2. I want for to get only one single result for each element of tb1. joining the two table may result on more than one result for each tb1 elements

tb1(id_tb1, other fileds)
tb2(id_tb2, (FK) id_tb1, other fields)

I was thinking is it possible to add some other fields to an active record query result.
Please help I need it soo much

Code:
$query1 = $this->db->get('tb1');
foreach($query1->result() as $row1){
$id_tb1 = $row1->id_tb1;
$this->db->where('id_tb1',$id_tb1);
$query2 = $this->db->get('tb2');
foreach( $query2->result() as $row2{
  add_row2_fields_to_query1($query1,$row2);
}

}




Theme © iAndrew 2016 - Forum software by © MyBB