Answer the question
In order to leave comments, you need to log in
Yii. How to link more than 2 tables in relations?
Hello, there are 3 tables, 1 - a list of all products, 2 - a link between a category and a product. 3 table - sorting products for each category. Now the code looks like this.
public function relations()
{
return array(
'contents' => array(self::MANY_MANY, 'Content', 'graph_index(graph_index_subgroup_id, content_id)'),
'publ_contents' => array(self::MANY_MANY, 'Content', 'graph_index(graph_index_subgroup_id, content_id)','condition'=>'publ_contents.is_publish = 0', ),
'unpubl_contents' => array(self::MANY_MANY, 'Content', 'graph_index(graph_index_subgroup_id, content_id)','condition'=>'unpubl_contents.is_publish = 1'),
'graphIndexGroups' => array(self::MANY_MANY, 'GraphIndexGroup', 'graph_index_subgroup_item(graph_index_subgroup_id, graph_index_group_id)'),
'graphIndexSubgroupItem' => array(self::HAS_ONE, 'GraphIndexSubgroupItem', 'graph_index_subgroup_id'),
);
}
'graph_index_subgroup_sort(graph_index_group_id, content_id)','order'=>'sort ASC'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question