Skip to content

Instantly share code, notes, and snippets.

@alborq
Created April 16, 2018 21:57
Show Gist options
  • Save alborq/5845834100423a3e421d04ef30a3fbfc to your computer and use it in GitHub Desktop.
Save alborq/5845834100423a3e421d04ef30a3fbfc to your computer and use it in GitHub Desktop.
<?php
use Blackprism\Nothing\HydratorCallable;
public function executeSomeQuery()
{
$this->createQueryBuilder()
->select('id', 'name', 'last_updated')
->from('user');
return array_map($queryBuilder->execute(), function($row) {
return new User(
$row['id'],
'prefixed ' . $row['name'],
new \DateTime($row['last_updated'])
);
});
}
foreach (executeSomeQuery() as $userId => $user) {
print_r($user);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment