class Result implements IDataSource

dibi result set.

$result = dibi::query('SELECT * FROM [table]');

$row   = $result->fetch();
$value = $result->fetchSingle();
$table = $result->fetchAll();
$pairs = $result->fetchPairs();
$assoc = $result->fetchAssoc('col1');
$assoc = $result->fetchAssoc('col1[]col2->col3');

unset($result);

Properties

int read-only $rowCount

Methods

__construct($driver)

No description

getResource() deprecated

No description

void
free()

Frees the resources allocated for this result set.

getResultDriver()

Safe access to property $driver.

bool
seek($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.

setRowClass($class)

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

string
getRowClass()

Returns fetched object class name.

setRowFactory(callable $callback)

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

Row|false
fetch()

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

mixed
fetchSingle()

Like fetch(), but returns only first field.

Row[]
fetchAll($offset = null, $limit = null)

Fetches all records from table.

array
fetchAssoc($assoc)

Fetches all records from table and returns associative tree.

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

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

setType($col, $type)

Define column type.

string
getType($col)

Returns column type.

setFormat($type, $format)

Sets date format.

string|null
getFormat($type)

Returns data format.

getInfo()

Returns a meta information about the current result set.

Column[]
getColumns()

No description

void
dump()

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

Details

at line 58
__construct($driver)

No description

Parameters

$driver

at line 68
final getResource() deprecated

deprecated

No description

at line 79
final void free()

Frees the resources allocated for this result set.

Return Value

void

at line 93
final ResultDriver getResultDriver()

Safe access to property $driver.

Return Value

ResultDriver

Exceptions

RuntimeException

at line 112
final bool seek($row)

Moves cursor position without fetching row.

Parameters

$row

Return Value

bool

true on success, false if unable to seek to specified record

Exceptions

Exception

at line 124
final int count()

Required by the Countable interface.

Return Value

int

at line 134
final int getRowCount()

Returns the number of rows in a result set.

Return Value

int

at line 144
final ResultIterator getIterator()

Required by the IteratorAggregate interface.

Return Value

ResultIterator

at line 158
Result setRowClass($class)

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

Parameters

$class

Return Value

Result

at line 169
string getRowClass()

Returns fetched object class name.

Return Value

string

at line 179
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 191
final Row|false fetch()

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

and moves the internal cursor to the next position

Return Value

Row|false

at line 212
final mixed fetchSingle()

Like fetch(), but returns only first field.

Return Value

mixed

value on success, false if no next record

at line 230
final Row[] fetchAll($offset = null, $limit = null)

Fetches all records from table.

Parameters

$offset
$limit

Return Value

Row[]

at line 263
final array fetchAssoc($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

$assoc

Return Value

array

Exceptions

InvalidArgumentException

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

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

Parameters

$key
$value

Return Value

array

Exceptions

InvalidArgumentException

at line 543
final Result setType($col, $type)

Define column type.

Parameters

$col
$type

Return Value

Result

at line 554
final string getType($col)

Returns column type.

Parameters

$col

Return Value

string

at line 566
final Result setFormat($type, $format)

Sets date format.

Parameters

$type
$format

Return Value

Result

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

Returns data format.

Parameters

$type

Return Value

string|null

at line 590
Result getInfo()

Returns a meta information about the current result set.

Return Value

Result

at line 602
final Column[] getColumns()

No description

Return Value

Column[]

at line 615
final void dump()

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

Return Value

void

Traits

Better OOP experience.