Class DibiDataSource


Default implementation of IDataSource for dibi.

DibiObject
   |
   --DibiDataSource

Implements interfaces:

IDataSource
Copyright: Copyright (c) 2005, 2010 David Grudl
Located: in /libs/DibiDataSource.php (line 21)
Constructor Summary
public
__construct (string $sql, DibiConnection $connection)
Method Summary
DibiDataSource
applyLimit (int $limit, [int $offset = NULL])
Limits number of rows.
int
count ()
Returns the number of rows in a given data source.
DibiRow|FALSE
fetch ()
Generates, executes SQL query and fetches the single row.
array
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.
mixed
Like fetch(), but returns only first field.
DibiConnection
Returns the dibi connection.
DibiResultIterator
DibiResult
Returns (and queries) DibiResult.
int
Returns the number of rows in a given data source.
DibiDataSource
orderBy (string|array $row, [string $sorting = 'ASC'])
Selects columns to order by.
void
release ()
Discards the internal cache.
DibiDataSource
select (string|array $col, [string $as = NULL])
Selects columns to query.
DibiDataSource
Returns this data source wrapped in DibiDataSource object.
DibiFluent
Returns this data source wrapped in DibiFluent object.
DibiDataSource
where (mixed $cond)
Adds conditions to query.
string
Returns SQL query.
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 59

__construct

public __construct (string $sql, DibiConnection $connection)

Input
string $sql SQL command or table or view name, as data source
DibiConnection $connection connection
Method Details

line 134

applyLimit

public DibiDataSource applyLimit (int $limit, [int $offset = NULL])

Limits number of rows.

Input
int $limit limit
int $offset offset
Output
DibiDataSource provides a fluent interface

line 303

count

public int count ()

Returns the number of rows in a given data source.

Output
int  

line 187

fetch

public DibiRow|FALSE fetch ()

Generates, executes SQL query and fetches the single row.

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

line 209

fetchAll

public array fetchAll ()

Fetches all records from table.

Output
array  

line 221

fetchAssoc

public array fetchAssoc (string $assoc)

Fetches all records from table and returns associative tree.

Input
string $assoc associative descriptor
Output
array  

line 234

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  

line 198

fetchSingle

public mixed fetchSingle ()

Like fetch(), but returns only first field.

Output
mixed value on success, FALSE if no next record

line 148

getConnection

public DibiConnection getConnection ()

Returns the dibi connection.

Output
DibiConnection  

line 176

getIterator

public DibiResultIterator getIterator ()

Output
DibiResultIterator  

line 163

getResult

public DibiResult getResult ()

Returns (and queries) DibiResult.

Output
DibiResult  

line 321

getTotalCount

public int getTotalCount ()

Returns the number of rows in a given data source.

Output
int  

line 115

orderBy

public DibiDataSource orderBy (string|array $row, [string $sorting = 'ASC'])

Selects columns to order by.

Input
string|array $row column name or array of column names
string $sorting sorting direction
Output
DibiDataSource provides a fluent interface

line 245

release

public void release ()

Discards the internal cache.

Output
void  

line 77

select

public DibiDataSource select (string|array $col, [string $as = NULL])

Selects columns to query.

Input
string|array $col column name or array of column names
string $as column alias
Output
DibiDataSource provides a fluent interface

line 271

toDataSource

public DibiDataSource toDataSource ()

Returns this data source wrapped in DibiDataSource object.

Output
DibiDataSource  

line 260

toFluent

public DibiFluent toFluent ()

Returns this data source wrapped in DibiFluent object.

Output
DibiFluent  

line 95

where

public DibiDataSource where (mixed $cond)

Adds conditions to query.

Input
mixed $cond conditions
Output
DibiDataSource provides a fluent interface

line 282

__toString

public string __toString ()

Returns SQL query.

Output
string