$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);
Show file
Open project: dg/dibi
Class Usage Examples
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 ( ) : |
Fetches the row at current position, process optional type conversion. | |
fetchAll ( $offset = NULL, $limit = NULL ) : |
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. |
Method | Description | |
---|---|---|
detectTypes ( ) : void | Autodetect column types. | |
normalize ( array &$row ) : void | Converts values to specified type and format. | |
oldFetchAssoc ( $assoc ) |
final public fetch ( ) : |
||
return | array on success, FALSE if no next record |
final public fetchAll ( $offset = NULL, $limit = NULL ) : |
||
return |
final public fetchAssoc ( $assoc ) : array | ||
return | array |
final public fetchPairs ( $key = NULL, $value = NULL ) : array | ||
return | array |
final public fetchSingle ( ) : mixed | ||
return | mixed | value on success, FALSE if no next record |
final public getColumns ( ) : Dibi\Reflection\Column[] | ||
return | Dibi\Reflection\Column[] |
public getInfo ( ) : Dibi\Reflection\Result | ||
return | Dibi\Reflection\Result |
final public getIterator ( ) : dibi\ResultIterator | ||
return | dibi\ResultIterator |
final public getResultDriver ( ) : dibi\ResultDriver | ||
return | dibi\ResultDriver |
public getRowClass ( ) : string | ||
return | string |
final public getRowCount ( ) : integer | ||
return | integer |
final public setFormat ( $type, $format ) : self | ||
return | self |
public setRowClass ( $class ) : self | ||
return | self |
public setRowFactory ( callable $callback ) : self | ||
$callback | callable | |
return | self |
final public setType ( $col, $type ) : self | ||
return | self |