PHP Class ParagonIE\EasyDB\EasyStatement

Show file Open project: paragonie/easydb Class Usage Examples

Public Methods

Method Description
__toString ( ) : string Convert the statement to a string.
andGroup ( ) : self Start a new grouping that will be applied with a logical "AND".
andIn ( string $condition, array $values ) : self Add an IN condition that will be applied with a logical "AND".
andWith ( string $condition, $values ) : self Add a condition that will be applied with a logical "AND".
end ( ) : self Alias for endGroup().
endGroup ( ) : self Exit the current grouping and return the parent statement.
group ( ) : self Alias for andGroup().
in ( string $condition, array $values ) : self Alias for andIn().
open ( ) : self Open a new statement.
orGroup ( ) : self Start a new grouping that will be applied with a logical "OR".
orIn ( string $condition, array $values ) : self Add an IN condition that will be applied with a logical "OR".
orWith ( string $condition, $values ) : self Add a condition that will be applied with a logical "OR".
sql ( ) : string Compile the current statement into PDO-ready SQL.
values ( ) : array Get all of the parameters attached to this statement.
with ( string $condition, $values ) : self Alias for andWith().

Protected Methods

Method Description
__construct ( EasyStatement $parent = null ) Don't instantiate directly. Instead, use open() (static method).
isGroup ( mixed $condition ) : boolean Check if a condition is a sub-group.

Private Methods

Method Description
unpackCondition ( string $condition, integer $count ) : string Replace a grouped placeholder with a list of placeholders.

Method Details

__construct() protected method

EasyStatement constructor.
protected __construct ( EasyStatement $parent = null )
$parent EasyStatement

__toString() public method

Convert the statement to a string.
public __toString ( ) : string
return string

andGroup() public method

Exit the group with endGroup().
public andGroup ( ) : self
return self

andIn() public method

Instead of using ? to denote the placeholder, ?* must be used!
public andIn ( string $condition, array $values ) : self
$condition string
$values array
return self

andWith() public method

Add a condition that will be applied with a logical "AND".
public andWith ( string $condition, $values ) : self
$condition string
$values
return self

end() public method

Alias for endGroup().
public end ( ) : self
return self

endGroup() public method

Exit the current grouping and return the parent statement.
public endGroup ( ) : self
return self

group() public method

Alias for andGroup().
public group ( ) : self
return self

in() public method

Alias for andIn().
public in ( string $condition, array $values ) : self
$condition string
$values array
return self

isGroup() protected method

Check if a condition is a sub-group.
protected isGroup ( mixed $condition ) : boolean
$condition mixed
return boolean

open() public static method

Open a new statement.
public static open ( ) : self
return self

orGroup() public method

Exit the group with endGroup().
public orGroup ( ) : self
return self

orIn() public method

Instead of using "?" to denote the placeholder, "?*" must be used!
public orIn ( string $condition, array $values ) : self
$condition string
$values array
return self

orWith() public method

Add a condition that will be applied with a logical "OR".
public orWith ( string $condition, $values ) : self
$condition string
$values
return self

sql() public method

Compile the current statement into PDO-ready SQL.
public sql ( ) : string
return string

values() public method

Get all of the parameters attached to this statement.
public values ( ) : array
return array

with() public method

Alias for andWith().
public with ( string $condition, $values ) : self
$condition string
return self