Skip to content

Instantly share code, notes, and snippets.

@damianoporta
Created November 3, 2015 23:35
Show Gist options
  • Save damianoporta/0084d87540e4231bbae7 to your computer and use it in GitHub Desktop.
Save damianoporta/0084d87540e4231bbae7 to your computer and use it in GitHub Desktop.
} else {
// Matching
$associationConditions = $this->association($options['association'])->conditions();
return $query
->join([
'table' => 'tags_associations',
'alias' => $options['association'],
'type' => 'INNER',
'conditions' => [
"{$options['association']}.foreign_key = Ads.id",
"{$options['association']}.model" => "Ads",
] + $associationConditions
])
->join([
'table' => 'tags',
'alias' => "{$options['association']}Tags",
'type' => 'INNER',
'conditions' => [
"{$options['association']}.tag_id = {$options['association']}Tags.id",
]
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment