Bitrix API

MysqliResult extends MysqliResult

Class Result is the abstract base class for representing database query result.

It has ability to transform raw data populated from the database into useful associative arrays with some fields unserialized and some presented as Datetime objects or other changes.

It also supports query debugging by providing [](\Bitrix\Main\Diag\SqlTracker) with timing information.

Table of Contents

Methods

__construct()  : mixed
addFetchDataModifier()  : void
Modifier should accept once fetched array as an argument, then modify by link or return new array: - function (&$data) { $data['AGE'] -= 7; } - function ($data) { $data['AGE'] -= 7; return $data; }
addReplacedAliases()  : void
Extends list of aliased columns.
fetch()  : array<string|int, mixed>|false
Fetches one row of the query result and returns it in the associative array of converted data or false on empty data.
fetchAll()  : array<string|int, mixed>
Fetches all the rows of the query result and returns it in the array of associative arrays.
fetchRaw()  : array<string|int, mixed>|false
Fetches one row of the query result and returns it in the associative array of raw DB data or false on empty data.
getConverters()  : array<string|int, callable>
getCount()  : int
Returns record count. It's required to set record count explicitly before.
getFields()  : null
Returns null because there is no way to know the fields.
getFieldsCount()  : int
Returns the number of fields in the result.
getIterator()  : Traversable
Retrieve an external iterator
getLength()  : int
Returns the size of the last fetched row.
getResource()  : null|resource
Returns database-specific resource of this result.
getSelectedRowsCount()  : int
Returns the number of rows in the result.
getTrackerQuery()  : SqlTrackerQuery|null
Returns current query tracker.
hasBigFields()  : bool
Checks the existence of the big fields in the result.
setConverters()  : mixed
setCount()  : mixed
Sets record count.
setReplacedAliases()  : void
Sets list of aliased columns.
setSerializedFields()  : void
Sets internal list of fields which will be unserialized on fetch.

Methods

__construct()

public __construct(resource $result[, Connection|null $dbConnection = null ][, SqlTrackerQuery|null $trackerQuery = null ]) : mixed
Parameters
$result : resource

Database-specific query result.

$dbConnection : Connection|null = null

Connection object.

$trackerQuery : SqlTrackerQuery|null = null

Helps to collect debug information.

addFetchDataModifier()

Modifier should accept once fetched array as an argument, then modify by link or return new array: - function (&$data) { $data['AGE'] -= 7; } - function ($data) { $data['AGE'] -= 7; return $data; }

public addFetchDataModifier(callable $fetchDataModifier) : void
Parameters
$fetchDataModifier : callable

Valid callback.

Tags
throws
ArgumentException

addReplacedAliases()

Extends list of aliased columns.

public addReplacedAliases(array<string|int, string> $replacedAliases) : void
Parameters
$replacedAliases : array<string|int, string>

Aliases map from tech to human.

Tags
see
Result::setReplacedAliases

fetch()

Fetches one row of the query result and returns it in the associative array of converted data or false on empty data.

public fetch([Converter|null $converter = null ]) : array<string|int, mixed>|false
Parameters
$converter : Converter|null = null

Optional converter to encode data on fetching.

Return values
array<string|int, mixed>|false

fetchAll()

Fetches all the rows of the query result and returns it in the array of associative arrays.

public fetchAll([Converter|null $converter = null ]) : array<string|int, mixed>

Returns an empty array if query has no data.

Parameters
$converter : Converter|null = null

Optional converter to encode data on fetching.

Return values
array<string|int, mixed>

fetchRaw()

Fetches one row of the query result and returns it in the associative array of raw DB data or false on empty data.

public fetchRaw() : array<string|int, mixed>|false
Return values
array<string|int, mixed>|false

getConverters()

public getConverters() : array<string|int, callable>
Return values
array<string|int, callable>

getCount()

Returns record count. It's required to set record count explicitly before.

public getCount() : int
Tags
throws
ObjectPropertyException
Return values
int

getFields()

Returns null because there is no way to know the fields.

public getFields() : null
Return values
null

getFieldsCount()

Returns the number of fields in the result.

public getFieldsCount() : int
Return values
int

getLength()

Returns the size of the last fetched row.

public getLength() : int
Return values
int

getResource()

Returns database-specific resource of this result.

public getResource() : null|resource
Return values
null|resource

getSelectedRowsCount()

Returns the number of rows in the result.

public getSelectedRowsCount() : int
Return values
int

hasBigFields()

Checks the existence of the big fields in the result.

public hasBigFields() : bool
Tags
inheritdoc
Return values
bool

setConverters()

public setConverters(array<string|int, callable> $converters) : mixed
Parameters
$converters : array<string|int, callable>

setCount()

Sets record count.

public setCount(int $n) : mixed
Parameters
$n : int

setReplacedAliases()

Sets list of aliased columns.

public setReplacedAliases(array<string|int, string> $replacedAliases) : void

This allows to overcome database limits on length of the column names.

Parameters
$replacedAliases : array<string|int, string>

Aliases map from tech to human.

Tags
see
Result::addReplacedAliases

setSerializedFields()

Sets internal list of fields which will be unserialized on fetch.

public setSerializedFields(array<string|int, mixed> $serializedFields) : void
Parameters
$serializedFields : array<string|int, mixed>

List of fields.


        
On this page

Search results