Created
July 15, 2012 05:38
-
-
Save dantman/3115181 to your computer and use it in GitHub Desktop.
Closure based result iterator
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 | |
class Application { | |
// [...] | |
function getOwners() { | |
$res = $db->select( | |
array( 'user', 'application_owner' ), | |
User::selectFields(), | |
array( 'ao_app' => $this->getID() ), | |
__METHOD__, | |
null, | |
array( 'application_owner' => array( 'LEFT JOIN', 'user_id=ap_user' ) ) | |
); | |
return new DatabaseResultIterator( $res, function( $row ) { | |
return User::newFromRow( $row ) | |
} ); | |
} | |
// [...] | |
} | |
// [...] | |
foreach ( $app->getOwners() as $user ) { | |
// [output row] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment