Tables:
registration_page stores instances of RegistrationPage model.
translation stores instances of Translation model.
translation_to_registration_page - holds associations between RegistrationPage and Translation (they’re MANY_MANY).
Model RegistrationPage has following relations:
public function relations()
{
return array(
'descriptionTranslations' => array(
self::MANY_MANY,
'Translation',
'{{translation_to_registration_page}}(page_id, translation_id)',
'condition' => 'page_item_type = :type', //'page_item_type' is in 'translation_to_registration_page' table
'params' => array(':type' => 'description'),
'index' => 'language_code',
),
'titleTranslations' => array(
self::MANY_MANY,
'Translation',
'{{translation_to_registration_page}}(page_id, translation_id)',
'condition' => 'page_item_type = :type', //'page_item_type' is in 'translation_to_registration_page' table
'params' => array(':type' => 'title'),
'index' => 'language_code',
),
);
}
Now I can’t use
$dataProvider = new CActiveDataProvider('RegistrationPage', array(
'criteria' => array(
'order' => 'weight',
'with' => array('descriptionTranslations', 'titleTranslations'),
),
because page_item_type parameter (in associations table) needs to be disambiguated. To do so I used relation name (titleTranslations, descriptionTranslations) BUT this failed because they refer to the table name of Translation model. So, how does association table aliased?
In other words - we have 3 tables:
registration_page - this is main table and aliased as ‘t’.
translation - this is joined table and aliased as relation name (‘titleTranslations’ or ‘descriptionTranslations’).
translation_to_registration_page - this is helper table, how is it aliased? Are there any rules?