A
A
Alexander2015-05-10 08:58:03
Yii
Alexander, 2015-05-10 08:58:03

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'),
    );
  }

How can I add something like that to 'publ_contents'
'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

1 answer(s)
V
vyachin, 2015-06-04
@vyachin

'publ_contents' => array(self::MANY_MANY, 'Content', 'graph_index(graph_index_subgroup_id, content_id)','condition'=>'publ_contents.is_publish = 0', 'with'=>[...... ...]),

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question