Walt
Walt

Reputation: 1531

Propel ORM with Two FK Columns To Same Foreign Table

I have a table that contains two foreign keys that map back to a membership table. They are named "from_member" and "to_member."

I am trying to get the Member object that represents this membership table by doing something like:

$feedbackQuery = FeedbackQuery::create()->findOne();
$fromMember = $feedbackQuery->getFromMember();

So that I can go like this:

$firstName = $fromMember->getFirstName();

The only problem is you can't do that, evidently Propel requires you to call $fedbackQuery->getMember()and who knows what that's going to return in this case.

Is there any easy way to accomplish getting the member data like this?

Upvotes: 1

Views: 643

Answers (1)

richrosa
richrosa

Reputation: 823

Assuming that you are using from_member_id and to_member_id as your foreign keys, you should have two methods at your disposal. getMemberRelatedByToMemberId() and getMemberRelatedByFromMemberId().

To find your from_member object and to use it.

$fromMember = $feedbackQuery->getMemberRelatedByToMemberId(); 
$firstname = $fromMember->getFirstName(); 

Upvotes: 3

Related Questions