PHP Class Contao\Database\Result

The class functions as a wrapper for the database result set and lazy loads the result rows when they are first requested. Usage: while ($result->next()) { echo $result->name; print_r($result->row()); }
ファイルを表示 Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$arrCache array Result cache
$resResult Doctrine\DBAL\Driver\Statement Database result
$resultSet array Result set
$strQuery string Query string

Public Methods

Method Description
__construct ( Doctrine\DBAL\Driver\Statement $statement, string $strQuery ) Validate the connection resource and store the query string
__destruct ( ) Automatically free the result
__get ( string $strKey ) : mixed | null Return an object property or a field of the current row
__isset ( mixed $strKey ) : boolean Check whether a field exists
__set ( mixed $strKey, string $varValue ) Set a particular field of the current row
count ( ) : integer Return the number of rows in the result set
fetchAllAssoc ( ) : array Fetch all rows as associative array
fetchAssoc ( ) : array | false Fetch the current row as associative array
fetchEach ( string $strKey ) : array Fetch a particular field of each row of the result
fetchField ( integer $intOffset ) : array Get the column information and return it as array
fetchRow ( ) : array | false Fetch the current row as enumerated array
first ( ) : Result | boolean Go to the first row of the current result
last ( ) : Result | boolean Go to the last row of the current result
next ( ) : Result | boolean Go to the next row of the current result
prev ( ) : Result | boolean Go to the previous row of the current result
reset ( ) : Result Reset the current result
row ( boolean $blnEnumerated = false ) : array Return the current row as associative array

Method Details

__construct() public method

Validate the connection resource and store the query string
public __construct ( Doctrine\DBAL\Driver\Statement $statement, string $strQuery )
$statement Doctrine\DBAL\Driver\Statement The database statement
$strQuery string The query string

__destruct() public method

Automatically free the result
public __destruct ( )

__get() public method

Return an object property or a field of the current row
public __get ( string $strKey ) : mixed | null
$strKey string The field name
return mixed | null The field value or null

__isset() public method

Check whether a field exists
public __isset ( mixed $strKey ) : boolean
$strKey mixed The field name
return boolean True if the field exists

__set() public method

Set a particular field of the current row
public __set ( mixed $strKey, string $varValue )
$strKey mixed The field name
$varValue string The field value

count() public method

Return the number of rows in the result set
public count ( ) : integer
return integer The number of rows

fetchAllAssoc() public method

Fetch all rows as associative array
public fetchAllAssoc ( ) : array
return array An array with all rows

fetchAssoc() public method

Fetch the current row as associative array
public fetchAssoc ( ) : array | false
return array | false The row as associative array or false if there is no row

fetchEach() public method

Fetch a particular field of each row of the result
public fetchEach ( string $strKey ) : array
$strKey string The field name
return array An array of field values

fetchField() public method

Get the column information and return it as array
public fetchField ( integer $intOffset ) : array
$intOffset integer The field offset
return array An array with the column information

fetchRow() public method

Fetch the current row as enumerated array
public fetchRow ( ) : array | false
return array | false The row as enumerated array or false if there is no row

first() public method

Go to the first row of the current result
public first ( ) : Result | boolean
return Result | boolean The result object or false if there is no first row

last() public method

Go to the last row of the current result
public last ( ) : Result | boolean
return Result | boolean The result object or false if there is no last row

next() public method

Go to the next row of the current result
public next ( ) : Result | boolean
return Result | boolean The result object or false if there is no next row

prev() public method

Go to the previous row of the current result
public prev ( ) : Result | boolean
return Result | boolean The result object or false if there is no previous row

reset() public method

Reset the current result
public reset ( ) : Result
return Result The result object

row() public method

Return the current row as associative array
public row ( boolean $blnEnumerated = false ) : array
$blnEnumerated boolean If true, an enumerated array will be returned
return array The row as array

Property Details

$arrCache protected_oe property

Result cache
protected array $arrCache
return array

$resResult protected_oe property

Database result
protected Statement,Doctrine\DBAL\Driver $resResult
return Doctrine\DBAL\Driver\Statement

$resultSet protected_oe property

Result set
protected array $resultSet
return array

$strQuery protected_oe property

Query string
protected string $strQuery
return string