MediaWiki REL1_35
Wikimedia\Rdbms\ResultWrapper Class Reference

Result wrapper for grabbing data queried from an IDatabase object. More...

Inheritance diagram for Wikimedia\Rdbms\ResultWrapper:
Collaboration diagram for Wikimedia\Rdbms\ResultWrapper:

Public Member Functions

 __construct (IDatabase $db, $result)
 
 count ()
 Get the number of rows in a result object.
 
 current ()
 
 fetchObject ()
 Fetch the next row from the given result object, in object form.
 
 fetchRow ()
 Fetch the next row from the given result object, in associative array form.
 
 free ()
 Free a result object.
 
 key ()
 
 next ()
 
 numRows ()
 Get the number of rows in a result object.
 
 rewind ()
 
 seek ( $pos)
 Change the position of the cursor in a result object.
 
 valid ()
 

Static Public Member Functions

static & unwrap (&$res)
 Get the underlying RDBMS driver-specific result resource.
 

Protected Attributes

stdClass bool null $currentRow
 
IDatabase $db
 
int $pos = 0
 
mixed null $result
 RDBMS driver-specific result resource.
 

Private Member Functions

 getDB ()
 

Detailed Description

Result wrapper for grabbing data queried from an IDatabase object.

Only IDatabase-related classes should construct these. Other code may use the FakeResultWrapper class for convenience or compatibility shims.

Note that using the Iterator methods in combination with the non-Iterator IDatabase result iteration functions may cause rows to be skipped or repeated.

By default, this will use the iteration methods of the IDatabase handle if provided. Subclasses can override methods to make it solely work on the result resource instead.

Definition at line 23 of file ResultWrapper.php.

Constructor & Destructor Documentation

◆ __construct()

Wikimedia\Rdbms\ResultWrapper::__construct ( IDatabase  $db,
  $result 
)
Parameters
IDatabase$dbDatabase handle that the result comes from
self | mixed$resultRDBMS driver-specific result resource

Definition at line 38 of file ResultWrapper.php.

References Wikimedia\Rdbms\ResultWrapper\$db, and Wikimedia\Rdbms\ResultWrapper\$result.

Member Function Documentation

◆ count()

Wikimedia\Rdbms\ResultWrapper::count ( )

Get the number of rows in a result object.

Returns
int

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 75 of file ResultWrapper.php.

◆ current()

Wikimedia\Rdbms\ResultWrapper::current ( )
Returns
stdClass|array|bool

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 107 of file ResultWrapper.php.

◆ fetchObject()

Wikimedia\Rdbms\ResultWrapper::fetchObject ( )

Fetch the next row from the given result object, in object form.

Fields can be retrieved with $row->fieldname, with fields acting like member variables. If no more rows are available, false is returned.

Returns
stdClass|bool
Exceptions
DBUnexpectedErrorThrown if the database returns an error

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 79 of file ResultWrapper.php.

References getDB().

◆ fetchRow()

Wikimedia\Rdbms\ResultWrapper::fetchRow ( )

Fetch the next row from the given result object, in associative array form.

Fields are retrieved with $row['fieldname']. If no more rows are available, false is returned.

Returns
array|bool
Exceptions
DBUnexpectedErrorThrown if the database returns an error

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 83 of file ResultWrapper.php.

References getDB().

◆ free()

Wikimedia\Rdbms\ResultWrapper::free ( )

Free a result object.

This either saves memory in PHP (buffered queries) or on the server (unbuffered queries). In general, queries are not large enough in result sets for this to be worth calling.

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 92 of file ResultWrapper.php.

◆ getDB()

Wikimedia\Rdbms\ResultWrapper::getDB ( )
private
Returns
IDatabase
Exceptions
RuntimeException

Definition at line 135 of file ResultWrapper.php.

Referenced by Wikimedia\Rdbms\ResultWrapper\numRows().

◆ key()

Wikimedia\Rdbms\ResultWrapper::key ( )
Returns
int

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 115 of file ResultWrapper.php.

◆ next()

Wikimedia\Rdbms\ResultWrapper::next ( )
Returns
stdClass PhanParamSignatureMismatchInternal

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 119 of file ResultWrapper.php.

◆ numRows()

Wikimedia\Rdbms\ResultWrapper::numRows ( )

Get the number of rows in a result object.

Returns
int

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 71 of file ResultWrapper.php.

References Wikimedia\Rdbms\ResultWrapper\getDB().

◆ rewind()

Wikimedia\Rdbms\ResultWrapper::rewind ( )

Definition at line 98 of file ResultWrapper.php.

References getDB().

◆ seek()

Wikimedia\Rdbms\ResultWrapper::seek (   $pos)

Change the position of the cursor in a result object.

See mysql_data_seek()

Parameters
int$pos

Implements Wikimedia\Rdbms\IResultWrapper.

Definition at line 87 of file ResultWrapper.php.

◆ unwrap()

static & Wikimedia\Rdbms\ResultWrapper::unwrap ( $res)
static

◆ valid()

Wikimedia\Rdbms\ResultWrapper::valid ( )

Definition at line 127 of file ResultWrapper.php.

Member Data Documentation

◆ $currentRow

stdClass bool null Wikimedia\Rdbms\ResultWrapper::$currentRow
protected

Definition at line 32 of file ResultWrapper.php.

◆ $db

IDatabase Wikimedia\Rdbms\ResultWrapper::$db
protected

Definition at line 25 of file ResultWrapper.php.

Referenced by Wikimedia\Rdbms\ResultWrapper\__construct().

◆ $pos

int Wikimedia\Rdbms\ResultWrapper::$pos = 0
protected

Definition at line 30 of file ResultWrapper.php.

◆ $result

mixed null Wikimedia\Rdbms\ResultWrapper::$result
protected

RDBMS driver-specific result resource.

Definition at line 27 of file ResultWrapper.php.

Referenced by Wikimedia\Rdbms\ResultWrapper\__construct().


The documentation for this class was generated from the following file: