How do I filter based on a joined table's columns in Propel?
Like:
$results = FooQuery::create()->joinBar()->filterByBarSurname('surname');
How do I filter based on a joined table's columns in Propel?
Like:
$results = FooQuery::create()->joinBar()->filterByBarSurname('surname');
You have to use use
method as described in the doc:
$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'
If you have to use join()
, I don't think you can use filterByXXX
method but the old where
:
$results = FooQuery::create()
->join('Foo.Bar')
->where('Bar.surname = ?', 'surname')
->find();
where
instead of filterByXXX
. –
Reamonn © 2022 - 2024 — McMap. All rights reserved.
join()
? – Epirus