Skip to content

Instantly share code, notes, and snippets.

@pmjones
Last active July 27, 2017 14:27
Show Gist options
  • Save pmjones/b17e41e86f8e2e01fbfd1eb56d4533b7 to your computer and use it in GitHub Desktop.
Save pmjones/b17e41e86f8e2e01fbfd1eb56d4533b7 to your computer and use it in GitHub Desktop.
// 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
'address.street AS street',
'address.city AS city',
])
->where('user.name = ?', 'romanb');
->fetchAll();
// Cf. http://atlasphp.io/mapper/direct.html#1-9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment