PHP Class Bluz\Db\Query\AbstractBuilder

Afficher le fichier Open project: bluzphp/framework

Protected Properties

Свойство Type Description
$aliases list of table aliases
$params the query parameters
$sql the complete SQL string for this query
$sqlParts the array of SQL parts collected
$types the parameter type map of this query

Méthodes publiques

Méthode Description
__toString ( ) : string Gets a string representation of this QueryBuilder which corresponds to the final SQL query being constructed.
execute ( ) : integer | string | array Execute this query using the bound parameters and their types
getParameter ( mixed $key ) : mixed Gets a (previously set) query parameter of the query being constructed
getParameters ( ) : array Gets all defined query parameters for the query being constructed
getQuery ( ) : string Return the complete SQL string formed for use
getQueryPart ( string $queryPartName ) : mixed Get a query part by its name
getSql ( ) : string Return the complete SQL string formed by the current specifications
setParameter ( string | integer $key, mixed $value, integer $type = PDO::PARAM_STR ) Sets a query parameter for the query being constructed
setParameters ( array $params, array $types = [] ) Sets a collection of query parameters for the query being constructed

Méthodes protégées

Méthode Description
addQueryPart ( string $sqlPartName, string | array $sqlPart, boolean $append = false ) Either appends to or replaces a single, generic query part
prepareCondition ( array $args = [] ) : string Prepare condition
resetQueryPart ( string $queryPartName ) Reset single SQL part
setFromQueryPart ( string $table ) setFromQueryPart

Method Details

__toString() public méthode

Gets a string representation of this QueryBuilder which corresponds to the final SQL query being constructed.
public __toString ( ) : string
Résultat string The string representation of this QueryBuilder.

addQueryPart() protected méthode

The available parts are: 'select', 'from', 'set', 'where', 'groupBy', 'having' and 'orderBy'
protected addQueryPart ( string $sqlPartName, string | array $sqlPart, boolean $append = false )
$sqlPartName string
$sqlPart string | array
$append boolean

execute() public méthode

Execute this query using the bound parameters and their types
public execute ( ) : integer | string | array
Résultat integer | string | array

getParameter() public méthode

Gets a (previously set) query parameter of the query being constructed
public getParameter ( mixed $key ) : mixed
$key mixed The key (index or name) of the bound parameter
Résultat mixed The value of the bound parameter.

getParameters() public méthode

Gets all defined query parameters for the query being constructed
public getParameters ( ) : array
Résultat array The currently defined query parameters

getQuery() public méthode

Example $sb = new SelectBuilder(); $sb ->select('u') ->from('User', 'u') ->where('id = ?', 42); echo $qb->getQuery(); // SELECT u FROM User u WHERE id = "42"
public getQuery ( ) : string
Résultat string

getQueryPart() public méthode

Get a query part by its name
public getQueryPart ( string $queryPartName ) : mixed
$queryPartName string
Résultat mixed

getSql() abstract public méthode

Example $sb = new SelectBuilder(); $sb ->select('u') ->from('User', 'u'); echo $qb->getSql(); // SELECT u FROM User u
abstract public getSql ( ) : string
Résultat string The SQL query string

prepareCondition() protected méthode

$builder->prepareCondition("WHERE id IN (?)", [..,..]);
protected prepareCondition ( array $args = [] ) : string
$args array
Résultat string

resetQueryPart() protected méthode

Reset single SQL part
protected resetQueryPart ( string $queryPartName )
$queryPartName string

setFromQueryPart() protected méthode

setFromQueryPart
protected setFromQueryPart ( string $table )
$table string

setParameter() public méthode

Example $sb = new SelectBuilder(); $sb ->select('u') ->from('users', 'u') ->where('u.id = :user_id') ->setParameter(':user_id', 1);
public setParameter ( string | integer $key, mixed $value, integer $type = PDO::PARAM_STR )
$key string | integer The parameter position or name
$value mixed The parameter value
$type integer PDO::PARAM_*

setParameters() public méthode

Example $sb = new SelectBuilder(); $sb ->select('u') ->from('users', 'u') ->where('u.id = :user_id1 OR u.id = :user_id2') ->setParameters([ ':user_id1' => 1, ':user_id2' => 2 ]);
public setParameters ( array $params, array $types = [] )
$params array The query parameters to set
$types array The query parameters types to set

Property Details

$aliases protected_oe property

list of table aliases
protected $aliases

$params protected_oe property

the query parameters
protected $params

$sql protected_oe property

the complete SQL string for this query
protected $sql

$sqlParts protected_oe property

the array of SQL parts collected
protected $sqlParts

$types protected_oe property

the parameter type map of this query
protected $types