I love the way populateRelation works, but in this particular case I really got stuk!
The schema is very simple:
event
id
title
user_id
user
id
name
user_tag
id
tag
user_tag_rel
user_id
tag_id
Now, what I need to do is to fetch 10 events with the related user and tags.
First option would be:
EventQuery::create()
->joinWithUser()
->useUserQuery()
->joinWithUserTag()
->endUse()
->limit(10)
->find();
Buu it's not possible tu use with()
on a many-to-many in conjunction with limit()
.
So I tried changing the joinWith
with simple join
and calling populateRelation('UserTag')
on the result, but Propel Says:
"Calling getRelation() on an unknown relation, UserTag"
Can anyone please tell me if there is any way to call the populateRelation() on the User object?
using joinWith does the exact same thing as with(), as far as not being able to use a limit.
You don't need to use the user query to join these columns. You can just do:
EventQuery::create()
->joinWithUser(Event.User)
->joinWithUserTag(User.UserTag)
->find();
If you want to use the limit, then do these as join's, with the Limit, and then run populateRelation afterwards (if you're doing joinWith you shouldn't need populateRelation, as those two should be redundant)