Last active
July 27, 2017 14:27
-
-
Save pmjones/b17e41e86f8e2e01fbfd1eb56d4533b7 to your computer and use it in GitHub Desktop.
This file contains 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 | |
'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