interface ResultInterface implements IteratorAggregate (View source)

Extension independent database result interface

Methods

getIterator()

Returns a generator that traverses through the whole result set and returns each row as an associative array

array
fetchAssoc()

Returns the next row of the result with associative keys

array
fetchRow()

Returns the next row of the result with numeric keys

string|false|null
fetchValue(int|string $field = 0)

Returns a single value from the given result; false on error

array
fetchAllAssoc()

Returns all rows of the result

array
fetchAllColumn(int|string $column = 0)

Returns values from the selected column of each row

array
fetchAllKeyPair()

Returns values as single dimensional array where the key is the first column and the value is the second column, e.g. "SELECT id, name FROM users" produces: ['123' => 'John', '124' => 'Jane']

int
numFields()

Returns the number of fields in the result

string|int
numRows()

Returns the number of rows in the result

bool
seek(int $offset)

Adjusts the result pointer to an arbitrary row in the result

array
getFieldsMeta()

Returns meta info for fields in $result

array
getFieldNames()

Returns the names of the fields in the result

Details

Generator getIterator()

Returns a generator that traverses through the whole result set and returns each row as an associative array

Return Value

Generator

array fetchAssoc()

Returns the next row of the result with associative keys

Return Value

array

array fetchRow()

Returns the next row of the result with numeric keys

Return Value

array

string|false|null fetchValue(int|string $field = 0)

Returns a single value from the given result; false on error

Parameters

int|string $field

Return Value

string|false|null

array fetchAllAssoc()

Returns all rows of the result

Return Value

array

array fetchAllColumn(int|string $column = 0)

Returns values from the selected column of each row

Parameters

int|string $column

Return Value

array

array fetchAllKeyPair()

Returns values as single dimensional array where the key is the first column and the value is the second column, e.g. "SELECT id, name FROM users" produces: ['123' => 'John', '124' => 'Jane']

Return Value

array

int numFields()

Returns the number of fields in the result

Return Value

int

string|int numRows()

Returns the number of rows in the result

Return Value

string|int

bool seek(int $offset)

Adjusts the result pointer to an arbitrary row in the result

Parameters

int $offset

offset to seek

Return Value

bool

True if the offset exists, false otherwise

array getFieldsMeta()

Returns meta info for fields in $result

Return Value

array

meta info for fields in $result

array getFieldNames()

Returns the names of the fields in the result

Return Value

array

Fields names