Get relational data through two fields relation

Hi folks. I need your valuable help. Let’s suppose i have that EER (i made it just for post here cause i cant show the real project).

I would like to do something like $document->availableSearchMethods() and get All of available SearchMethod models. It seems easy and i think it is but i just cant figure out how i could do that cause there is a condition: i just want to get the SearchMethods that have the the same id_type and id_operation like my document.

How could i do that in a Yii way?

I am doing it for use a static method like Document::availableSearchMethods($id_type, $id_operation) that returns me an array of SearchMethod objects.

I just would like to know if there is a way to do that using relations and/or scopes.

I would really appreciate your opinions!

Thanks in advance.

Something here? ::)

If you post the models that require to be related or the tables, we could provide you with some help… otherwise, is difficult to know.

What you are asking is something very easy as for relations is concerned. Please review this article on the guide, it may bring some light: http://www.yiiframework.com/doc/guide/1.1/en/database.arr

Cheers

I will make a new project based on that i showed and post the gii code here more some implementations 'cause i cant post the real project code here.

Thanks.

I have already made so many relationships in many projects (HAS_MANY, MANY_MANY, BELONGS_TO… and so on) but this is a special case not covered in documentation.

For now, what relations would you make to link Document to SearchMethod in this case, having the mentioned conditions?

Thanks for your reply.

Post your table fields and we try to help you :) (I cannot see the EER)

Maybe now you could see. :)

I will post the codes soon.

tnx