3 abstract class UserArray
implements Iterator
{
5 * @param $res ResultWrapper
6 * @return UserArrayFromResult
8 static function newFromResult( $res ) {
10 if ( !wfRunHooks( 'UserArrayFromResult', array( &$userArray, $res ) ) ) {
13 if ( $userArray === null ) {
14 $userArray = self
::newFromResult_internal( $res );
21 * @return UserArrayFromResult
23 static function newFromIDs( $ids ) {
24 $ids = array_map( 'intval', (array)$ids ); // paranoia
26 // Database::select() doesn't like empty arrays
27 return new ArrayIterator(array());
29 $dbr = wfGetDB( DB_SLAVE
);
30 $res = $dbr->select( 'user', '*', array( 'user_id' => $ids ),
32 return self
::newFromResult( $res );
37 * @return UserArrayFromResult
39 protected static function newFromResult_internal( $res ) {
40 return new UserArrayFromResult( $res );
44 class UserArrayFromResult
extends UserArray
{
53 * @param $res ResultWrapper
55 function __construct( $res ) {
58 $this->setCurrent( $this->res
->current() );
65 protected function setCurrent( $row ) {
66 if ( $row === false ) {
67 $this->current
= false;
69 $this->current
= User
::newFromRow( $row );
76 public function count() {
77 return $this->res
->numRows();
84 return $this->current
;
92 $row = $this->res
->next();
93 $this->setCurrent( $row );
100 $this->setCurrent( $this->res
->current() );
107 return $this->current
!== false;