Created
April 16, 2018 21:57
-
-
Save alborq/5845834100423a3e421d04ef30a3fbfc 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
<?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