Hi,
I’'ve got some trouble describing the relations for my class :
I have a class named "Category" which is used to store categories and subcategories.
Subcategories are related to their parent category through a parent_category_id which is the id (in the same Category table) of the parent category.
I don’t know how to overload the relations method in the model class.
I tried so far :
public function relations()
{
return array(
'subcategories'=>array(self::HAS_MANY,'Category','parent_category_id'),
'parentcategory'=>array(self::BELONGS_TO,'Category','id'),
);
}
but I’m not sure that this is the right way to do : when I try to display the parent category name in a view, using $data->parentcategory->name, I got the category name (and not the parent category name)
Any clue/advice ?
thks in advance and sorry for the bad english
Marc