There are 4 tables:
results: ResID | ResCodeConc | ResName | ResDate
marks (points): MarkID | MarkCodeResult | MarkExp
conclusions (conclusion): ConcID | Concname
conc_fields (fields): FieldID | FieldCodeNameConc | Fieldname
One result has many points, one-to-many relationship.
The result is of type (ResCodeConс) from the table of conclusions, one to one relation.
In turn, the conclusions (conclusions) has many fields, one to many.
I did it in the Results model:
'marks' => array(self::HAS_MANY, 'Marks', 'MarkCodeResult'), 'conclusions' => array(self::BELONGS_TO, 'Conclusions',array('ResCodeConc '=>'ConcID ')), 'conc_fields' => array(self::HAS_MANY, 'ConcFields', array('ConcID '=>'FieldCodeNameConc'),'through'=>'conclusions')
Separately, everything works, i.e .: separate conclusion fields:
foreach($results->conc_fields as $field) echo $field->FieldName;
separate points:
foreach($results->marks as $mark) echo $mark->MarkExp;
But you can't do it like this, the name of the field is the FieldName score | MarkExp
conc_fields
INNER JOINconclusions
ON ON f.FieldCodeNameConc = n.ConcID SELECT m.MarkExp FROMmarks
m INNER JOINresults