Class DibiFluent


dibi SQL builder via fluent interfaces. EXPERIMENTAL!

DibiObject
   |
   --DibiFluent

Implements interfaces:

IDataSource
Copyright: Copyright (c) 2005, 2010 David Grudl
Located: in /libs/DibiFluent.php (line 21)
Constructor Summary
public
__construct (DibiConnection $connection)
Method Summary
DibiFluent
clause (string $clause, [$remove = FALSE])
Switch to a clause.
int
count ()
DibiResult|int
execute ([mixed $return = NULL])
Generates and executes SQL query.
DibiRow|FALSE
fetch ()
Generates, executes SQL query and fetches the single row.
array
fetchAll ([int $offset = NULL], [int $limit = NULL])
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.
string
Returns SQL command.
DibiConnection
Returns the dibi connection.
bool
getFlag (string $flag)
Is a flag set?
DibiResultIterator
getIterator ([int $offset = NULL], [int $limit = NULL])
Required by the IteratorAggregate interface.
DibiFluent
removeClause (string $clause)
Removes a clause.
DibiFluent
setFlag (string $flag, [bool $value = TRUE])
Change a SQL flag.
bool
test ([string $clause = NULL])
Generates and prints SQL query or it's part.
DibiDataSource
protected array
_export ([string $clause = NULL], [$args = array()])
Generates parameters for DibiTranslator.
DibiFluent
__call (string $clause, array $args)
Appends new argument to the clause.
void
__clone ()
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()
Constant Summary
bool REMOVE FALSE

line 23

Variable Summary
static array $masks array( 'SELECT' => array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'GROUP BY', 'HAVING',...

line 26

static array $modifiers array( 'SELECT' => '%n', 'FROM' => '%n', 'IN' => '%in', 'VALUES' => '%l',...

line 35

default modifiers for arrays
static array $separators array( 'SELECT' => ',', 'FROM' => FALSE, 'WHERE' => 'AND', 'GROUP BY' =>...

line 48

clauses separators

Constructor Details

line 82

__construct

public __construct (DibiConnection $connection)

Input
DibiConnection $connection
Method Details

line 176

clause

public DibiFluent clause (string $clause, [$remove = FALSE])

Switch to a clause.

Input
string $clause clause name
$remove
Output
DibiFluent provides a fluent interface

line 373

count

public int count ()

Output
int  

line 269

execute

public DibiResult|int execute ([mixed $return = NULL])

Generates and executes SQL query.

Input
mixed $return what to return?
Output
DibiResult|int result set object (if any)
Throws
throws DibiException

line 281

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 313

fetchAll

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

Fetches all records from table.

Input
int $offset offset
int $limit limit
Output
array  

line 325

fetchAssoc

public array fetchAssoc (string $assoc)

Fetches all records from table and returns associative tree.

Input
string $assoc associative descriptor
Output
array  

line 338

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 296

fetchSingle

public mixed fetchSingle ()

Like fetch(), but returns only first field.

Output
mixed value on success, FALSE if no next record

line 241

getCommand

public string getCommand ()

Returns SQL command.

Output
string  

line 252

getConnection

public DibiConnection getConnection ()

Returns the dibi connection.

Output
DibiConnection  

line 230

getFlag

public bool getFlag (string $flag)

Is a flag set?

Input
string $flag flag name
Output
bool  

line 351

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 198

removeClause

public DibiFluent removeClause (string $clause)

Removes a clause.

Input
string $clause clause name
Output
DibiFluent provides a fluent interface

line 212

setFlag

public DibiFluent setFlag (string $flag, [bool $value = TRUE])

Change a SQL flag.

Input
string $flag flag name
bool $value value
Output
DibiFluent provides a fluent interface

line 363

test

public bool test ([string $clause = NULL])

Generates and prints SQL query or it's part.

Input
string $clause clause name
Output
bool  

line 389

toDataSource

public DibiDataSource toDataSource ()

Output
DibiDataSource  

line 412

_export

protected array _export ([string $clause = NULL], [$args = array()])

Generates parameters for DibiTranslator.

Input
string $clause clause name
$args
Output
array  

line 95

__call

public DibiFluent __call (string $clause, array $args)

Appends new argument to the clause.

Input
string $clause clause name
array $args arguments
Output
DibiFluent provides a fluent interface

line 458

__clone

public void __clone ()

Output
void  

line 400

__toString

public string __toString ()

Returns SQL query.

Output
string