class Result implements IDataSource

Query result.

Properties

int read-only $rowCount

Methods

__construct(ResultDriver $driver, bool $normalize = true)

No description

void
free()

Frees the resources allocated for this result set.

getResultDriver()

Safe access to property $driver.

bool
seek(int $row)

Moves cursor position without fetching row.

int
count()

Required by the Countable interface.

int
getRowCount()

Returns the number of rows in a result set.

getIterator()

Required by the IteratorAggregate interface.

int
getColumnCount()

Returns the number of columns in a result set.

setRowClass(string|null $class)

Set fetched object class. This class should extend the Row class.

string|null
getRowClass()

Returns fetched object class name.

setRowFactory(callable $callback)

Set a factory to create fetched object instances. These should extend the Row class.

Row|array|null
fetch()

Fetches the row at current position, process optional type conversion.

mixed
fetchSingle()

Like fetch(), but returns only first field.

array
fetchAll(int $offset = null, int $limit = null)

Fetches all records from table.

array
fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

array
fetchPairs(string $key = null, string $value = null)

Fetches all records from table like $key => $value pairs.

setType(string $column, string|null $type)

Define column type.

string|null
getType(string $column)

Returns column type.

array
getTypes()

Returns columns type.

setFormat(string $type, string|null $format)

Sets type format.

setFormats(array $formats)

Sets type formats.

string|null
getFormat(string $type)

Returns data format.

getInfo()

Returns a meta information about the current result set.

array
getColumns()

No description

void
dump()

Displays complete result set as HTML or text table for debug purposes.

Details

at line 44
__construct(ResultDriver $driver, bool $normalize = true)

No description

Parameters

ResultDriver $driver
bool $normalize

at line 56
final void free()

Frees the resources allocated for this result set.

Return Value

void

at line 69
final ResultDriver getResultDriver()

Safe access to property $driver.

Return Value

ResultDriver

Exceptions

RuntimeException

at line 86
final bool seek(int $row)

Moves cursor position without fetching row.

Parameters

int $row

Return Value

bool

Exceptions

Exception

at line 97
final int count()

Required by the Countable interface.

Return Value

int

at line 106
final int getRowCount()

Returns the number of rows in a result set.

Return Value

int

at line 115
final ResultIterator getIterator()

Required by the IteratorAggregate interface.

Return Value

ResultIterator

at line 124
final int getColumnCount()

Returns the number of columns in a result set.

Return Value

int

at line 136
Result setRowClass(string|null $class)

Set fetched object class. This class should extend the Row class.

Parameters

string|null $class

Return Value

Result

at line 146
string|null getRowClass()

Returns fetched object class name.

Return Value

string|null

at line 155
Result setRowFactory(callable $callback)

Set a factory to create fetched object instances. These should extend the Row class.

Parameters

callable $callback

Return Value

Result

at line 167
final Row|array|null fetch()

Fetches the row at current position, process optional type conversion.

and moves the internal cursor to the next position

Return Value

Row|array|null

at line 188
final mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed

value on success, null if no next record

at line 204
final array fetchAll(int $offset = null, int $limit = null)

Fetches all records from table.

Parameters

int $offset
int $limit

Return Value

array

at line 235
final array fetchAssoc(string $assoc)

Fetches all records from table and returns associative tree.

Examples:

  • associative descriptor: col1[]col2->col3 builds a tree: $tree[$val1][$index][$val2]->col3[$val3] = {record}
  • associative descriptor: col1|col2->col3=col4 builds a tree: $tree[$val1][$val2]->col3[$val3] = val4

Parameters

string $assoc

Return Value

array

Exceptions

InvalidArgumentException

at line 379
final array fetchPairs(string $key = null, string $value = null)

Fetches all records from table like $key => $value pairs.

Parameters

string $key
string $value

Return Value

array

Exceptions

InvalidArgumentException

at line 528
final Result setType(string $column, string|null $type)

Define column type.

Parameters

string $column
string|null $type

use constant Type::*

Return Value

Result

at line 538
final string|null getType(string $column)

Returns column type.

Parameters

string $column

Return Value

string|null

at line 547
final array getTypes()

Returns columns type.

Return Value

array

at line 556
final Result setFormat(string $type, string|null $format)

Sets type format.

Parameters

string $type
string|null $format

Return Value

Result

at line 566
final Result setFormats(array $formats)

Sets type formats.

Parameters

array $formats

Return Value

Result

at line 576
final string|null getFormat(string $type)

Returns data format.

Parameters

string $type

Return Value

string|null

at line 588
Result getInfo()

Returns a meta information about the current result set.

Return Value

Result

at line 598
final array getColumns()

No description

Return Value

array

at line 610
final void dump()

Displays complete result set as HTML or text table for debug purposes.

Return Value

void

Traits

Better OOP experience.