如何基于Propel中的联接表格列进行过滤?
像:
$results = FooQuery::create()->joinBar()->filterByBarSurname('surname');
答案 0 :(得分:7)
您必须使用in the doc所述的use
方法:
$results = FooQuery::create()
->useBarQuery()
->filterBySurname('surname')
->endUse()
->find();
// example Query generated for a MySQL database
$query = 'SELECT foo.* from foo
INNER JOIN bar ON foo.BAR_ID = bar.ID
WHERE bar.SURNAME = :p1'; // :p1 => 'surname'
如果您必须使用join()
,我认为您不能使用filterByXXX
方法,而是旧版where
:
$results = FooQuery::create()
->join('Foo.Bar')
->where('Bar.surname = ?', 'surname')
->find();