This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class DiscussionRepository | |
| { | |
| public function __construct(DiscussionMapper $mapper) {...} | |
| public function fetchDiscussion($id) | |
| { | |
| $record = $this->mapper->select(['discussion_id' => $id]) | |
| ->with(['author']); | |
| return $this->newDiscussion($record); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // given that you have created UserMapper and AddressMapper, | |
| // and set up a 1:1 relationship from UserMapper to AddressMapper named 'address': | |
| $atlas | |
| ->select(UserMapper::CLASS) // "FROM user" | |
| ->joinWith('address') // the name of the relationship field | |
| ->cols([ | |
| 'user.id AS id', | |
| 'user.name AS name', | |
| 'address.id AS address_id', // aliased using the relationship field name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * | |
| * This file is part of Atlas for PHP. | |
| * | |
| * @license http://opensource.org/licenses/mit-license.php MIT | |
| * | |
| */ | |
| declare(strict_types=1); |
OlderNewer