PHP Class Pagekit\Database\Query\QueryBuilder

Afficher le fichier Open project: pagekit/pagekit Class Usage Examples

Protected Properties

Свойство Type Description
$connection Pagekit\Database\Connection The Connection.
$params array The query parameters.
$parts array The query parts.

Méthodes publiques

Méthode Description
__construct ( Pagekit\Database\Connection $connection ) Constructor.
__toString ( ) {@see QueryBuilder::getSQL}
addPart ( string $name, mixed $parts ) : self Adds a query part.
aggregate ( string $function, string $column ) : mixed Execute the query with an aggregate function.
avg ( string $column ) : mixed Execute the query and get the "avg" result.
count ( string $column = '*' ) : integer Execute the query and get the "count" result.
delete ( ) : integer Execute the "delete" query.
execute ( mixed $columns = ['*'] ) : Doctrine\DBAL\Driver\Statement Execute the "select" query.
first ( mixed $columns = ['*'] ) : mixed Execute the query and get the first result.
from ( string $table ) : self Creates and sets a "from" to the query.
get ( mixed $columns = ['*'] ) : array Execute the query and get all results.
getConnection ( ) : Pagekit\Database\Connection Gets the connection for the query builder.
getPart ( string $name ) : mixed Gets a query part by its name.
getParts ( ) : array Gets all query parts.
getSQL ( ) : string Gets the query SQL.
groupBy ( mixed $groupBy ) : self Creates and adds a "group by" to the query.
having ( mixed $having, string $type = CompositeExpression::TYPE_AND ) : self Creates and adds a "having" to the query.
innerJoin ( string $table, string $condition = null ) : self Creates and adds an "inner join" to the query.
join ( string $table, string $condition = null, string $type = 'inner' ) : self Creates and adds a "join" to the query.
leftJoin ( string $table, string $condition = null ) : self Creates and adds a "left join" to the query.
limit ( integer $limit ) : self Sets the limit of the query.
max ( string $column ) : mixed Execute the query and get the "max" result.
min ( string $column ) : mixed Execute the query and get the "min" result.
offset ( integer $offset ) : self Sets the offset of the query.
orHaving ( mixed $having ) : self Creates and adds a "or having" to the query.
orWhere ( mixed $condition, array $params = [] ) : self Creates and adds a "or where" to the query.
orWhereExists ( Closure $callback, boolean $not = false ) : self Creates and adds a "or where exists" to the query.
orWhereIn ( string $column, mixed $values, boolean $not = false ) : self Creates and adds a "or where in" to the query.
orderBy ( string $sort, string $order = null ) : self Creates and adds an "order by" to the query.
params ( array $params = null ) : array | self Get or set multiple query parameters.
rightJoin ( string $table, string $condition = null ) : self Creates and adds a "right join" to the query.
select ( mixed $columns = ['*'] ) : self Creates and adds a "select" to the query.
setPart ( string $name, mixed $parts ) : self Sets a query part and replaces all previous values.
sum ( string $column ) : mixed Execute the query and get the "sum" result.
update ( array $values ) : integer Execute the "update" query with the given values.
where ( mixed $condition, array $params = [] ) : self Creates and adds a "where" to the query.
whereExists ( Closure $callback, boolean $not = false, string $type = null ) : self Creates and adds a "where exists" to the query.
whereIn ( string $column, mixed $values, boolean $not = false, string $type = null ) : self Creates and adds a "where in" to the query.
whereInSet ( string $column, mixed $values, boolean $not = false, string $type = null ) : self Creates and adds a "where FIND_IN_SET" equivalent to the query.

Méthodes protégées

Méthode Description
addWhere ( mixed $condition, array $params, string $type = null ) : self Creates and adds a "where" to the query.
executeQuery ( string $type = 'select' ) : mixed Execute the query as select, update or delete.
getSQLForDelete ( ) : string Creates the "delete" SQL string from the query parts.
getSQLForSelect ( ) : string Creates the "select" SQL string from the query parts.
getSQLForUpdate ( ) : string Creates the "update" SQL string from the query parts.
guessParamTypes ( array $params = [] ) : array Tries to guess param types
newQuery ( ) : QueryBuilder Creates a new query builder.
parameter ( $name )

Method Details

__construct() public méthode

Constructor.
public __construct ( Pagekit\Database\Connection $connection )
$connection Pagekit\Database\Connection

__toString() public méthode

{@see QueryBuilder::getSQL}
public __toString ( )

addPart() public méthode

Adds a query part.
public addPart ( string $name, mixed $parts ) : self
$name string
$parts mixed
Résultat self

addWhere() protected méthode

Creates and adds a "where" to the query.
protected addWhere ( mixed $condition, array $params, string $type = null ) : self
$condition mixed
$params array
$type string
Résultat self

aggregate() public méthode

Execute the query with an aggregate function.
public aggregate ( string $function, string $column ) : mixed
$function string
$column string
Résultat mixed

avg() public méthode

Execute the query and get the "avg" result.
public avg ( string $column ) : mixed
$column string
Résultat mixed

count() public méthode

Execute the query and get the "count" result.
public count ( string $column = '*' ) : integer
$column string
Résultat integer

delete() public méthode

Execute the "delete" query.
public delete ( ) : integer
Résultat integer

execute() public méthode

Execute the "select" query.
public execute ( mixed $columns = ['*'] ) : Doctrine\DBAL\Driver\Statement
$columns mixed
Résultat Doctrine\DBAL\Driver\Statement

executeQuery() protected méthode

Execute the query as select, update or delete.
protected executeQuery ( string $type = 'select' ) : mixed
$type string
Résultat mixed

first() public méthode

Execute the query and get the first result.
public first ( mixed $columns = ['*'] ) : mixed
$columns mixed
Résultat mixed

from() public méthode

Creates and sets a "from" to the query.
public from ( string $table ) : self
$table string
Résultat self

get() public méthode

Execute the query and get all results.
public get ( mixed $columns = ['*'] ) : array
$columns mixed
Résultat array

getConnection() public méthode

Gets the connection for the query builder.
public getConnection ( ) : Pagekit\Database\Connection
Résultat Pagekit\Database\Connection

getPart() public méthode

Gets a query part by its name.
public getPart ( string $name ) : mixed
$name string
Résultat mixed

getParts() public méthode

Gets all query parts.
public getParts ( ) : array
Résultat array

getSQL() public méthode

Gets the query SQL.
public getSQL ( ) : string
Résultat string

getSQLForDelete() protected méthode

Creates the "delete" SQL string from the query parts.
protected getSQLForDelete ( ) : string
Résultat string

getSQLForSelect() protected méthode

Creates the "select" SQL string from the query parts.
protected getSQLForSelect ( ) : string
Résultat string

getSQLForUpdate() protected méthode

Creates the "update" SQL string from the query parts.
protected getSQLForUpdate ( ) : string
Résultat string

groupBy() public méthode

Creates and adds a "group by" to the query.
public groupBy ( mixed $groupBy ) : self
$groupBy mixed
Résultat self

guessParamTypes() protected méthode

Tries to guess param types
protected guessParamTypes ( array $params = [] ) : array
$params array
Résultat array

having() public méthode

Creates and adds a "having" to the query.
public having ( mixed $having, string $type = CompositeExpression::TYPE_AND ) : self
$having mixed
$type string
Résultat self

innerJoin() public méthode

Creates and adds an "inner join" to the query.
public innerJoin ( string $table, string $condition = null ) : self
$table string
$condition string
Résultat self

join() public méthode

Creates and adds a "join" to the query.
public join ( string $table, string $condition = null, string $type = 'inner' ) : self
$table string
$condition string
$type string
Résultat self

leftJoin() public méthode

Creates and adds a "left join" to the query.
public leftJoin ( string $table, string $condition = null ) : self
$table string
$condition string
Résultat self

limit() public méthode

Sets the limit of the query.
public limit ( integer $limit ) : self
$limit integer
Résultat self

max() public méthode

Execute the query and get the "max" result.
public max ( string $column ) : mixed
$column string
Résultat mixed

min() public méthode

Execute the query and get the "min" result.
public min ( string $column ) : mixed
$column string
Résultat mixed

newQuery() protected méthode

Creates a new query builder.
protected newQuery ( ) : QueryBuilder
Résultat QueryBuilder

offset() public méthode

Sets the offset of the query.
public offset ( integer $offset ) : self
$offset integer
Résultat self

orHaving() public méthode

Creates and adds a "or having" to the query.
public orHaving ( mixed $having ) : self
$having mixed
Résultat self

orWhere() public méthode

Creates and adds a "or where" to the query.
public orWhere ( mixed $condition, array $params = [] ) : self
$condition mixed
$params array
Résultat self

orWhereExists() public méthode

Creates and adds a "or where exists" to the query.
public orWhereExists ( Closure $callback, boolean $not = false ) : self
$callback Closure
$not boolean
Résultat self

orWhereIn() public méthode

Creates and adds a "or where in" to the query.
public orWhereIn ( string $column, mixed $values, boolean $not = false ) : self
$column string
$values mixed
$not boolean
Résultat self

orderBy() public méthode

Creates and adds an "order by" to the query.
public orderBy ( string $sort, string $order = null ) : self
$sort string
$order string
Résultat self

parameter() protected méthode

protected parameter ( $name )

params() public méthode

Get or set multiple query parameters.
public params ( array $params = null ) : array | self
$params array
Résultat array | self

rightJoin() public méthode

Creates and adds a "right join" to the query.
public rightJoin ( string $table, string $condition = null ) : self
$table string
$condition string
Résultat self

select() public méthode

Creates and adds a "select" to the query.
public select ( mixed $columns = ['*'] ) : self
$columns mixed
Résultat self

setPart() public méthode

Sets a query part and replaces all previous values.
public setPart ( string $name, mixed $parts ) : self
$name string
$parts mixed
Résultat self

sum() public méthode

Execute the query and get the "sum" result.
public sum ( string $column ) : mixed
$column string
Résultat mixed

update() public méthode

Execute the "update" query with the given values.
public update ( array $values ) : integer
$values array
Résultat integer

where() public méthode

Creates and adds a "where" to the query.
public where ( mixed $condition, array $params = [] ) : self
$condition mixed
$params array
Résultat self

whereExists() public méthode

Creates and adds a "where exists" to the query.
public whereExists ( Closure $callback, boolean $not = false, string $type = null ) : self
$callback Closure
$not boolean
$type string
Résultat self

whereIn() public méthode

Creates and adds a "where in" to the query.
public whereIn ( string $column, mixed $values, boolean $not = false, string $type = null ) : self
$column string
$values mixed
$not boolean
$type string
Résultat self

whereInSet() public méthode

Creates and adds a "where FIND_IN_SET" equivalent to the query.
public whereInSet ( string $column, mixed $values, boolean $not = false, string $type = null ) : self
$column string
$values mixed
$not boolean
$type string
Résultat self

Property Details

$connection protected_oe property

The Connection.
protected Connection,Pagekit\Database $connection
Résultat Pagekit\Database\Connection

$params protected_oe property

The query parameters.
protected array $params
Résultat array

$parts protected_oe property

The query parts.
protected array $parts
Résultat array