Welcome Guest, Not a member yet? Register   Sign In
Using joins?
#1

[eluser]chefnelone[/eluser]
Hello,

I'm usign this active record(which works fine):

Code:
$this->db->join('categories', 'categories.id_category = products.category_id'  , 'left');


but... I need to join categories based in the value of $category_id instead of based in the value of of the field: products.category_id.

Something like: (not working)
Code:
$category_id = 228;
$this->db->join('categories', 'categories.id_category = '.$category_id , 'left');


I know I've got a problem with logic of the tables and I'll have to make some changes with them... but I need to solve this now.
Any ideas?
Thanks
#2

[eluser]Stoney[/eluser]
You can do it like this:
Code:
$this->db->join('categories', 'categories.id_category = products.category_id'  , 'left');
$this->db->where('categories.id_category','228')
#3

[eluser]Unknown[/eluser]
try this...
$category_id = 228;

#4

[eluser]chefnelone[/eluser]
cimet solution works fine.
thanks




Theme © iAndrew 2016 - Forum software by © MyBB