MediaWiki REL1_33
UserArray.php
Go to the documentation of this file.
1<?php
24
25abstract class UserArray implements Iterator {
30 static function newFromResult( $res ) {
31 $userArray = null;
32 if ( !Hooks::run( 'UserArrayFromResult', [ &$userArray, $res ] ) ) {
33 return null;
34 }
35 if ( $userArray === null ) {
36 $userArray = self::newFromResult_internal( $res );
37 }
38 return $userArray;
39 }
40
45 static function newFromIDs( $ids ) {
46 $ids = array_map( 'intval', (array)$ids ); // paranoia
47 if ( !$ids ) {
48 // Database::select() doesn't like empty arrays
49 return new ArrayIterator( [] );
50 }
52 $userQuery = User::getQueryInfo();
53 $res = $dbr->select(
54 $userQuery['tables'],
55 $userQuery['fields'],
56 [ 'user_id' => array_unique( $ids ) ],
57 __METHOD__,
58 [],
59 $userQuery['joins']
60 );
61 return self::newFromResult( $res );
62 }
63
69 static function newFromNames( $names ) {
70 $names = array_map( 'strval', (array)$names ); // paranoia
71 if ( !$names ) {
72 // Database::select() doesn't like empty arrays
73 return new ArrayIterator( [] );
74 }
76 $userQuery = User::getQueryInfo();
77 $res = $dbr->select(
78 $userQuery['tables'],
79 $userQuery['fields'],
80 [ 'user_name' => array_unique( $names ) ],
81 __METHOD__,
82 [],
83 $userQuery['joins']
84 );
85 return self::newFromResult( $res );
86 }
87
92 protected static function newFromResult_internal( $res ) {
93 return new UserArrayFromResult( $res );
94 }
95}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
static newFromResult( $res)
Definition UserArray.php:30
static newFromIDs( $ids)
Definition UserArray.php:45
static newFromNames( $names)
Definition UserArray.php:69
static newFromResult_internal( $res)
Definition UserArray.php:92
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new user object.
Definition User.php:5643
$res
Definition database.txt:21
Result wrapper for grabbing data queried from an IDatabase object.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
const DB_REPLICA
Definition defines.php:25