I have a MANY_MANY relation:
'rel'=>array(self::MANY_MANY, 'MyClass','table(id_1,id_2)',
'condition'=>'some condiotions AND field_name=:param')
I get the result -instances of Myclass in the siteController:
$obj->rel
Is it possible (and how) to pass the :param from the controller to the relation's query?
You can try "Parameterized Named Scopes":
Then you can use it this way:
I'm pretty sure that it's not possible, but what you want to do can be achieved in a different way.
Check the following from the Guide:
So your query could be something like this (if we want to use eager loading approach):
Or when using the lazy loading approach to perform relational query:
Hope this helps. Do read the linked guide. Ask for clarifications, if needed.
Edit:
As already mentioned in the comments below,
some conditions
can be put in the model's relation, and only additional conditions need to be specified while querying. The additional condition is automaticallyAND
'ed to the model's relation condition. This seems contrary to the documentation. Anyway the following code can be used:Controller:
Also see this comment in the linked documentation