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 26)
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 64

__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 139

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 308

count

public int count ()

Returns the number of rows in a given data source.

Output
int  

line 192

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 214

fetchAll

public array fetchAll ()

Fetches all records from table.

Output
array  

line 226

fetchAssoc

public array fetchAssoc (string $assoc)

Fetches all records from table and returns associative tree.

Input
string $assoc associative descriptor
Output
array  

line 239

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 203

fetchSingle

public mixed fetchSingle ()

Like fetch(), but returns only first field.

Output
mixed value on success, FALSE if no next record

line 153

getConnection

public DibiConnection getConnection ()

Returns the dibi connection.

Output
DibiConnection  

line 181

getIterator

public DibiResultIterator getIterator ()

Output
DibiResultIterator  

line 168

getResult

public DibiResult getResult ()

Returns (and queries) DibiResult.

Output
DibiResult  

line 326

getTotalCount

public int getTotalCount ()

Returns the number of rows in a given data source.

Output
int  

line 120

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 250

release

public void release ()

Discards the internal cache.

Output
void  

line 82

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 276

toDataSource

public DibiDataSource toDataSource ()

Returns this data source wrapped in DibiDataSource object.

Output
DibiDataSource  

line 265

toFluent

public DibiFluent toFluent ()

Returns this data source wrapped in DibiFluent object.

Output
DibiFluent  

line 100

where

public DibiDataSource where (mixed $cond)

Adds conditions to query.

Input
mixed $cond conditions
Output
DibiDataSource provides a fluent interface

line 287

__toString

public string __toString ()

Returns SQL query.

Output
string