GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
If you need to manually build a query that relies on a relation defined in an ActiveRecord it is hard to get the name of the many-many-table for MANY_MANY relation.
I can already get the relation by calling $model->getActiveRelation('relationName') which gives me an instance of CManyManyRelation.
But there I only have the foreignKey property which I would have to parse with the same regex as it is done in CActiveFinder.php line 561.
It would be nice if I had a property of CManyManyRelation that gives me the table.
I started an implementation of that by moving the 7 lines after 561 to a method called getRelationTable() in CManyManyRelation. But there are many problems with that:
Giving the $model and $schema as parameters of the getter does not seem to be a good solution to me.
So things to change for that to work are much more than I thought in the beginning.
I think a CActiveRelation should have information about which activerecord it belongs to, what do you thing @qiangxue @samdark?
That might not have become clear: If the relation knows its activerecord model or even just the class name of it, implementation would be very easy.
this has been resolved by #878.