Skip to content

Instantly share code, notes, and snippets.

<?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);
// 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
<?php
/**
*
* This file is part of Atlas for PHP.
*
* @license http://opensource.org/licenses/mit-license.php MIT
*
*/
declare(strict_types=1);