Skip to content

Commit

Permalink
DOC Use table name, not class name. (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed May 13, 2024
1 parent 164b66f commit 100dbf2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions en/02_Developer_Guides/00_Model/02_Relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 100dbf2

Please sign in to comment.