MediaWiki  REL1_24
UserArray.php
Go to the documentation of this file.
00001 <?php
00023 abstract class UserArray implements Iterator {
00028     static function newFromResult( $res ) {
00029         $userArray = null;
00030         if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) {
00031             return null;
00032         }
00033         if ( $userArray === null ) {
00034             $userArray = self::newFromResult_internal( $res );
00035         }
00036         return $userArray;
00037     }
00038 
00043     static function newFromIDs( $ids ) {
00044         $ids = array_map( 'intval', (array)$ids ); // paranoia
00045         if ( !$ids ) {
00046             // Database::select() doesn't like empty arrays
00047             return new ArrayIterator( array() );
00048         }
00049         $dbr = wfGetDB( DB_SLAVE );
00050         $res = $dbr->select(
00051             'user',
00052             User::selectFields(),
00053             array( 'user_id' => array_unique( $ids ) ),
00054             __METHOD__
00055         );
00056         return self::newFromResult( $res );
00057     }
00058 
00063     protected static function newFromResult_internal( $res ) {
00064         return new UserArrayFromResult( $res );
00065     }
00066 }