Skip to content

Commit

Permalink
#41 Change embedded.md examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin V / vvval committed Dec 31, 2019
1 parent 3f56e02 commit 801a29b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions relation/embedded.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ You can query embedded entities as your would do for any other relation:

```php
$select = $orm->getRepository(User::class)->select();
$select->where('address.country', 'USA');
$select->where('credentials.username', 'username');
```

## Eager and Lazy Loading
Expand All @@ -81,16 +81,16 @@ class User
/** @Column(type = "primary") */
public $id;

/** @Embedded(target = "Address", load = "lazy") */
public $address;
/** @Embedded(target = "UserCredentials", load = "lazy") */
public $credentials;
}
```

Now, in order to pre-load embedded entity you have to explicitly use the `load()` method of your select:

```php
$select = $orm->getRepository(User::class)->select();
$select->where('address.country', 'USA');
$select->where('credentials.username', 'username');

print_r($select->load('address')->fetchAll());
print_r($select->load('credentials')->fetchAll());
```

0 comments on commit 801a29b

Please sign in to comment.