Reputation: 517
I have three tables (objects). The Foo table has a 1:N relationship defined with the table Bar. The table FooBar is used to define a different N:M relationship between A and B.
I want to select all objects in Foo which have either a 1:N relationship with Bar and/or a N:M relationship using the same Criteria. So far, what I have is two different Criteria for each:
$c1n = new Criteria();
$c1n->addJoin(FooPeer::ID, BarPeer::FOO_ID);
$cnm = new Criteria();
$cnm->addJoin(FooPeer::ID, FooBarPeer::FOO_ID);
$objects1N = FooPeer::doSelect($c1n);
$objectsNM = FooPeer::doSelect($cnm);
Is it possible to include both in the same criteria? And if it is, how can I achieve that?
Upvotes: 0
Views: 32
Reputation: 985
You can't do this directly, but see if this works for what you are looking for:
find query for many to many relation propel
You should be able to easily hydrate the 1:N relationship.
foreach($query as $result) {
$result->getBar()->getColumnName();
}
Upvotes: 1