Skip to content

Instantly share code, notes, and snippets.

@simodima
Last active October 21, 2016 08:10
Show Gist options
  • Save simodima/6746c5698e8175a6dc144322afbcf214 to your computer and use it in GitHub Desktop.
Save simodima/6746c5698e8175a6dc144322afbcf214 to your computer and use it in GitHub Desktop.
<?php
public function getAllIds()
{
$expr = $this->_em->getExpressionBuilder();
$rsm = new ResultSetMapping();
$rsm->addScalarResult('id', 'id');
$result = $this->_em->createNativeQuery('
SELECT u.id as id FROM users u
UNION
SELECT a.id as id FROM social_account a
', $rsm)->iterate();
foreach ($result as $item) {
$dto = array_shift($item);
yield new Id($dto['id']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment