[eluser]Ty Bex[/eluser]
I am joining 2 tables with columns that have the same name "NAME" and "ID"
The problem is I would expect to get the name and id from each product according to my select.
Is there a way to get the result of each column that I am selecting?
TABLE ecom_product
Code:
-----------------------------------------
|ID | ACTIVE | NAME | LEVEL |
-----------------------------------------
| 3 | 1 | Product 3 Name | 0 |
-----------------------------------------
TABLE ecom_level
Code:
-----------------
|ID | NAME |
-----------------
| 0 | Senior |
| 1 | Junior |
-----------------
Code:
$this->db->select('p.id, p.active, p.name, l.name');
$this->db->from('ecom_product as p', FALSE);
$this->db->join('ecom_level as l', 'p.level = l.id', 'left');
$this->db->where('p.active', true);
$this->db->where('p.id', $id);
$this->db->limit(1);
$Q = $this->db->get();
if ($Q->num_rows() > 0){
$row = $Q->row();
print_r($row);
exit;
#return $row;
}
RESULT
stdClass Object ( [id] => 3 [active] => 1 [name] => Senior )