Class DibiResult


dibi result-set.

  1. 1:  $result dibi::query('SELECT * FROM [table]');
  2. 2:  
  3. 3:  $row   $result->fetch();
  4. 4:  $value $result->fetchSingle();
  5. 5:  $table $result->fetchAll();
  6. 6:  $pairs $result->fetchPairs();
  7. 7:  $assoc $result->fetchAssoc('id');
  8. 8:  $assoc $result->fetchAssoc('active,#,id');
  9. 9:  
  10. 10:  unset($result);

DibiObject
   |
   --DibiResult

Implements interfaces:

IDataSource
Copyright: Copyright (c) 2005, 2010 David Grudl
Located: in /libs/DibiResult.php (line 34)
Constructor Summary
public
__construct (IDibiDriver $driver, array $config)
Method Summary
protected mixed
convert (mixed $value, int $type)
Converts value to specified type and format.
int
count ()
Required by the Countable interface.
void
Autodetect column types.
void
dump ()
Displays complete result-set as HTML table for debug purposes.
DibiRow|FALSE
fetch ()
Fetches the row at current position, process optional type conversion.
array
fetchAll ([int $offset = NULL], [int $limit = NULL])
Fetches all records from table.
DibiRow
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.
mixed
Like fetch(), but returns only first field.
void
free ()
Frees the resources allocated for this result set.
void
getColumnNames ([$fullNames = FALSE])
void
DibiResultInfo
getInfo ()
Returns a meta information about the current result set.
DibiResultIterator
getIterator ([int $offset = NULL], [int $limit = NULL])
Required by the IteratorAggregate interface.
mixed
Returns the result set resource.
string
Returns fetched object class name.
int
Returns the number of rows in a result set.
string
getType ($col)
Returns column type.
void
Returns the number of rows in a result set. Alias for getRowCount().
boolean
seek (int $row)
Moves cursor position without fetching row.
DibiResult
setRowClass (string $class)
Set fetched object class. This class should extend the DibiRow class.
DibiResult
setType (string $col, string $type)
Define column type.
DibiResult
setTypes ($types)
Define multiple columns types.
Methods Inherited From DibiObject
DibiObject::extensionMethod(), DibiObject::getClass(), DibiObject::getReflection(), DibiObject::__call(), DibiObject::__callStatic(), DibiObject::__get(), DibiObject::__isset(), DibiObject::__set(), DibiObject::__unset()

Constructor Details

line 60

__construct

public __construct (IDibiDriver $driver, array $config)

Input
IDibiDriver $driver
array $config
Method Details

line 552

convert

protected mixed convert (mixed $value, int $type)

Converts value to specified type and format.

Input
mixed $value value
int $type type
Output
mixed  

line 137

count

public int count ()

Required by the Countable interface.

Output
int  

line 512

detectTypes

public void detectTypes ()

Autodetect column types.

Output
void  

line 642

dump

public void dump ()

Displays complete result-set as HTML table for debug purposes.

Output
void  

line 212

fetch

public DibiRow|FALSE fetch ()

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

and moves the internal cursor to the next position

Output
DibiRow|FALSE array on success, FALSE if no next record

line 261

fetchAll

public array fetchAll ([int $offset = NULL], [int $limit = NULL])

Fetches all records from table.

Input
int $offset offset
int $limit limit
Output
array of DibiRow

line 291

fetchAssoc

public DibiRow 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

Input
string $assoc associative descriptor
Output
DibiRow  
Throws
throws InvalidArgumentException

line 439

fetchPairs

public array fetchPairs ([string $key = NULL], [string $value = NULL])

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

Input
string $key associative key
string $value value
Output
array  
Throws
throws InvalidArgumentException

line 237

fetchSingle

public mixed fetchSingle ()

Like fetch(), but returns only first field.

Output
mixed value on success, FALSE if no next record

line 90

free

public void free ()

Frees the resources allocated for this result set.

Output
void  

line 627

getColumnNames

public void getColumnNames ([$fullNames = FALSE])

Input
$fullNames
Output
void  
Tags
Deprecated

line 617

getColumns

public void getColumns ()

Output
void  
Tags
Deprecated

line 604

getInfo

public DibiResultInfo getInfo ()

Returns a meta information about the current result set.

Output
DibiResultInfo  

line 172

getIterator

public DibiResultIterator getIterator ([int $offset = NULL], [int $limit = NULL])

Required by the IteratorAggregate interface.

Input
int $offset offset
int $limit limit
Output
DibiResultIterator  

line 79

getResource

public mixed getResource ()

Returns the result set resource.

Output
mixed  

line 200

getRowClass

public string getRowClass ()

Returns fetched object class name.

Output
string  

line 148

getRowCount

public int getRowCount ()

Returns the number of rows in a result set.

Output
int  

line 539

getType

public string getType ($col)

Returns column type.

Input
$col
Output
string  

line 159

rowCount

public void rowCount ()

Returns the number of rows in a result set. Alias for getRowCount().

Output
void  
Tags
Deprecated

line 126

seek

public boolean seek (int $row)

Moves cursor position without fetching row.

Input
int $row the 0-based cursor pos to seek to
Output
boolean TRUE on success, FALSE if unable to seek to specified record
Throws
throws DibiException

line 188

setRowClass

public DibiResult setRowClass (string $class)

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

Input
string $class
Output
DibiResult provides a fluent interface

line 500

setType

public DibiResult setType (string $col, string $type)

Define column type.

Input
string $col column
string $type type (use constant Dibi::*)
Output
DibiResult provides a fluent interface

line 527

setTypes

public DibiResult setTypes ($types)

Define multiple columns types.

Input
$types
Output
DibiResult provides a fluent interface