diff --git a/docs/en/02_Developer_Guides/00_Model/02_Relations.md b/docs/en/02_Developer_Guides/00_Model/02_Relations.md index 5f0ff2e04..c9842c73e 100644 --- a/docs/en/02_Developer_Guides/00_Model/02_Relations.md +++ b/docs/en/02_Developer_Guides/00_Model/02_Relations.md @@ -12,12 +12,18 @@ SilverStripe supports a number of relationship types and each relationship type ## has_one -A 1-to-1 relation creates a database-column called "``ID", in the example below this would be -"TeamID" on the "Player"-table. +Many-to-1 and 1-to-1 relationships create a database-column called "``ID", in the example below this would be "TeamID" on the "Player"-table. ```php use SilverStripe\ORM\DataObject; +class Player extends DataObject +{ + private static $has_one = [ + "Team" => "Team", + ]; +} + class Team extends DataObject { private static $db = [ @@ -28,12 +34,6 @@ class Team extends DataObject 'Players' => 'Player' ]; } -class Player extends DataObject -{ - private static $has_one = [ - "Team" => "Team", - ]; -} ``` This defines a relationship called `Team` which links to a `Team` class. The `ORM` handles navigating the relationship