Skip to content

Instantly share code, notes, and snippets.

@CarlosEduardo
Created July 27, 2017 15:52
Show Gist options
  • Save CarlosEduardo/6b69fa6650b43c966a0e1d0d794dfa68 to your computer and use it in GitHub Desktop.
Save CarlosEduardo/6b69fa6650b43c966a0e1d0d794dfa68 to your computer and use it in GitHub Desktop.
<?php
// "NativeQuery" like http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/native-sql.html
$nativeQuery = 'SELECT user.id AS id, user.name AS name, address.id AS address_id, address.street AS street, address.city AS city ' .
'FROM user INNER JOIN address ON address.id = user.address_id ' .
'WHERE user.name = :name';
$atlas
->nativeQuery($nativeQuery)
->bindValue('name', 'romanb')
->addMapper(UserMapper::class, 'user', ['id', 'name'])
->addMapper(AddressMapper::class, 'address', ['address_id' => 'id', 'street', 'city'])
->fetchAll();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment