PHP Class Dibi\Result

$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);
Inheritance: implements IDataSource, use trait dibi\Strict
显示文件 Open project: dg/dibi Class Usage Examples

Public Methods

Method Description
__construct ( $driver )
count ( ) : integer Required by the Countable interface.
dump ( ) : void Displays complete result set as HTML or text table for debug purposes.
fetch ( ) : Row | FALSE Fetches the row at current position, process optional type conversion.
fetchAll ( $offset = NULL, $limit = NULL ) : Row[] Fetches all records from table.
fetchAssoc ( $assoc ) : array Fetches all records from table and returns associative tree.
fetchPairs ( $key = NULL, $value = NULL ) : array Fetches all records from table like $key => $value pairs.
fetchSingle ( ) : mixed Like fetch(), but returns only first field.
free ( ) : void Frees the resources allocated for this result set.
getColumns ( ) : Dibi\Reflection\Column[]
getFormat ( $type ) : string Returns data format.
getInfo ( ) : Dibi\Reflection\Result Returns a meta information about the current result set.
getIterator ( ) : dibi\ResultIterator Required by the IteratorAggregate interface.
getResource ( )
getResultDriver ( ) : dibi\ResultDriver Safe access to property $driver.
getRowClass ( ) : string Returns fetched object class name.
getRowCount ( ) : integer Returns the number of rows in a result set.
getType ( $col ) : string Returns column type.
seek ( $row ) : boolean Moves cursor position without fetching row.
setFormat ( $type, $format ) : self Sets data format.
setRowClass ( $class ) : self Set fetched object class. This class should extend the Row class.
setRowFactory ( callable $callback ) : self Set a factory to create fetched object instances. These should extend the Row class.
setType ( $col, $type ) : self Define column type.

Private Methods

Method Description
detectTypes ( ) : void Autodetect column types.
normalize ( array &$row ) : void Converts values to specified type and format.
oldFetchAssoc ( $assoc )

Method Details

__construct() public method

public __construct ( $driver )

count() final public method

Required by the Countable interface.
final public count ( ) : integer
return integer

dump() final public method

Displays complete result set as HTML or text table for debug purposes.
final public dump ( ) : void
return void

fetch() final public method

and moves the internal cursor to the next position
final public fetch ( ) : Row | FALSE
return Row | FALSE array on success, FALSE if no next record

fetchAll() final public method

Fetches all records from table.
final public fetchAll ( $offset = NULL, $limit = NULL ) : Row[]
return Row[]

fetchAssoc() final public method

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
final public fetchAssoc ( $assoc ) : array
return array

fetchPairs() final public method

Fetches all records from table like $key => $value pairs.
final public fetchPairs ( $key = NULL, $value = NULL ) : array
return array

fetchSingle() final public method

Like fetch(), but returns only first field.
final public fetchSingle ( ) : mixed
return mixed value on success, FALSE if no next record

free() final public method

Frees the resources allocated for this result set.
final public free ( ) : void
return void

getColumns() final public method

final public getColumns ( ) : Dibi\Reflection\Column[]
return Dibi\Reflection\Column[]

getFormat() final public method

Returns data format.
final public getFormat ( $type ) : string
return string

getInfo() public method

Returns a meta information about the current result set.
public getInfo ( ) : Dibi\Reflection\Result
return Dibi\Reflection\Result

getIterator() final public method

Required by the IteratorAggregate interface.
final public getIterator ( ) : dibi\ResultIterator
return dibi\ResultIterator

getResource() final public method

Deprecation:
final public getResource ( )

getResultDriver() final public method

Safe access to property $driver.
final public getResultDriver ( ) : dibi\ResultDriver
return dibi\ResultDriver

getRowClass() public method

Returns fetched object class name.
public getRowClass ( ) : string
return string

getRowCount() final public method

Returns the number of rows in a result set.
final public getRowCount ( ) : integer
return integer

getType() final public method

Returns column type.
final public getType ( $col ) : string
return string

seek() final public method

Moves cursor position without fetching row.
final public seek ( $row ) : boolean
return boolean TRUE on success, FALSE if unable to seek to specified record

setFormat() final public method

Sets data format.
final public setFormat ( $type, $format ) : self
return self

setRowClass() public method

Set fetched object class. This class should extend the Row class.
public setRowClass ( $class ) : self
return self

setRowFactory() public method

Set a factory to create fetched object instances. These should extend the Row class.
public setRowFactory ( callable $callback ) : self
$callback callable
return self

setType() final public method

Define column type.
final public setType ( $col, $type ) : self
return self