3 abstract class UserArray
implements Iterator
{
7 * @return UserArrayFromResult
9 static function newFromResult( $res ) {
11 if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) {
14 if ( $userArray === null ) {
15 $userArray = self
::newFromResult_internal( $res );
22 * @return UserArrayFromResult
24 static function newFromIDs( $ids ) {
25 $ids = array_map( 'intval', (array)$ids ); // paranoia
27 // Database::select() doesn't like empty arrays
28 return new ArrayIterator(array());
30 $dbr = wfGetDB( DB_SLAVE
);
31 $res = $dbr->select( 'user', '*', array( 'user_id' => $ids ),
33 return self
::newFromResult( $res );
36 protected static function newFromResult_internal( $res ) {
37 $userArray = new UserArrayFromResult( $res );
42 class UserArrayFromResult
extends UserArray
{
46 function __construct( $res ) {
49 $this->setCurrent( $this->res
->current() );
52 protected function setCurrent( $row ) {
53 if ( $row === false ) {
54 $this->current
= false;
56 $this->current
= User
::newFromRow( $row );
60 public function count() {
61 return $this->res
->numRows();
65 return $this->current
;
73 $row = $this->res
->next();
74 $this->setCurrent( $row );
81 $this->setCurrent( $this->res
->current() );
85 return $this->current
!== false;