Skip to content

Instantly share code, notes, and snippets.

@damour
Created September 18, 2013 14:08
Show Gist options
  • Save damour/6609649 to your computer and use it in GitHub Desktop.
Save damour/6609649 to your computer and use it in GitHub Desktop.
array(
'select' => array(
"COALESCE(
{$this->translationClass}1.name,
{$this->translationClass}3.name,
{$this->translationClass}2.name
) AS name",
"COALESCE(
{$this->translationClass}1.description,
{$this->translationClass}3.description,
{$this->translationClass}2.description
) AS description",
),
'alias' => "{$this->translationClass}1",
'on' => "{$this->translationClass}1.language_id = ".Yii::app()->params->currentLangId,
'join' => "
LEFT OUTER JOIN {$this->languageRelation} {$this->translationClass}2
ON ({$this->translationClass}3.{$this->translationForeignKey}={$this->translationClass}2.{$this->translationForeignKey})
LEFT OUTER JOIN {$this->languageRelation} {$this->translationClass}3
ON ({$this->translationClass}3.language_id = ".arLanguages::defaultLanguage()." AND
{$this->translationClass}3.{$this->translationForeignKey}={$this->translationClass}1.{$this->translationForeignKey})
"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment