3 abstract class UserArray
implements Iterator
{
4 static function newFromResult( $res ) {
6 if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) {
9 if ( $userArray === null ) {
10 $userArray = self
::newFromResult_internal( $res );
15 static function newFromIDs( $ids ) {
16 $ids = array_map( 'intval', (array)$ids ); // paranoia
18 // Database::select() doesn't like empty arrays
19 return new ArrayIterator(array());
20 $dbr = wfGetDB( DB_SLAVE
);
21 $res = $dbr->select( 'user', '*', array( 'user_id' => $ids ),
23 return self
::newFromResult( $res );
26 protected static function newFromResult_internal( $res ) {
27 $userArray = new UserArrayFromResult( $res );
32 class UserArrayFromResult
extends UserArray
{
36 function __construct( $res ) {
39 $this->setCurrent( $this->res
->current() );
42 protected function setCurrent( $row ) {
43 if ( $row === false ) {
44 $this->current
= false;
46 $this->current
= User
::newFromRow( $row );
50 public function count() {
51 return $this->res
->numRows();
55 return $this->current
;
63 $row = $this->res
->next();
64 $this->setCurrent( $row );
71 $this->setCurrent( $this->res
->current() );
75 return $this->current
!== false;