From 4b56b595e070e20fbfcdbedf84bc75c45c211d0f Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 10 May 2024 13:07:05 +1200 Subject: [PATCH] DOC Use table name, not class name. --- en/02_Developer_Guides/00_Model/02_Relations.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/en/02_Developer_Guides/00_Model/02_Relations.md b/en/02_Developer_Guides/00_Model/02_Relations.md index 78692331d..1cc4bf791 100644 --- a/en/02_Developer_Guides/00_Model/02_Relations.md +++ b/en/02_Developer_Guides/00_Model/02_Relations.md @@ -498,12 +498,15 @@ class TeamSupporter extends DataObject } ``` -In order to filter on the join table during queries, you can use the class name of the joining table +In order to filter on the join table during queries, you can use the table name of the joining table for any sql conditions. ```php -$team = Team::get()->byId(1); -$supporters = $team->Supporters()->where(['"TeamSupporter"."Ranking"' => 1]); +use SilverStripe\ORM\DataObject; + +$rankingColumn = DataObject::getSchema()->sqlColumnForField(TeamSupporter::class, 'Ranking'); +$team = Team::get()->byID(1); +$supporters = $team->Supporters()->where([$rankingColumn => 1]); ``` Note: ->filter() currently does not support joined fields natively due to the fact that the