PHP Класс Pagekit\Database\Query\QueryBuilder

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$connection Pagekit\Database\Connection The Connection.
$params array The query parameters.
$parts array The query parts.

Открытые методы

Метод Описание
__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.

Защищенные методы

Метод Описание
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 )

Описание методов

__construct() публичный Метод

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

__toString() публичный Метод

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

addPart() публичный Метод

Adds a query part.
public addPart ( string $name, mixed $parts ) : self
$name string
$parts mixed
Результат self

addWhere() защищенный Метод

Creates and adds a "where" to the query.
protected addWhere ( mixed $condition, array $params, string $type = null ) : self
$condition mixed
$params array
$type string
Результат self

aggregate() публичный Метод

Execute the query with an aggregate function.
public aggregate ( string $function, string $column ) : mixed
$function string
$column string
Результат mixed

avg() публичный Метод

Execute the query and get the "avg" result.
public avg ( string $column ) : mixed
$column string
Результат mixed

count() публичный Метод

Execute the query and get the "count" result.
public count ( string $column = '*' ) : integer
$column string
Результат integer

delete() публичный Метод

Execute the "delete" query.
public delete ( ) : integer
Результат integer

execute() публичный Метод

Execute the "select" query.
public execute ( mixed $columns = ['*'] ) : Doctrine\DBAL\Driver\Statement
$columns mixed
Результат Doctrine\DBAL\Driver\Statement

executeQuery() защищенный Метод

Execute the query as select, update or delete.
protected executeQuery ( string $type = 'select' ) : mixed
$type string
Результат mixed

first() публичный Метод

Execute the query and get the first result.
public first ( mixed $columns = ['*'] ) : mixed
$columns mixed
Результат mixed

from() публичный Метод

Creates and sets a "from" to the query.
public from ( string $table ) : self
$table string
Результат self

get() публичный Метод

Execute the query and get all results.
public get ( mixed $columns = ['*'] ) : array
$columns mixed
Результат array

getConnection() публичный Метод

Gets the connection for the query builder.
public getConnection ( ) : Pagekit\Database\Connection
Результат Pagekit\Database\Connection

getPart() публичный Метод

Gets a query part by its name.
public getPart ( string $name ) : mixed
$name string
Результат mixed

getParts() публичный Метод

Gets all query parts.
public getParts ( ) : array
Результат array

getSQL() публичный Метод

Gets the query SQL.
public getSQL ( ) : string
Результат string

getSQLForDelete() защищенный Метод

Creates the "delete" SQL string from the query parts.
protected getSQLForDelete ( ) : string
Результат string

getSQLForSelect() защищенный Метод

Creates the "select" SQL string from the query parts.
protected getSQLForSelect ( ) : string
Результат string

getSQLForUpdate() защищенный Метод

Creates the "update" SQL string from the query parts.
protected getSQLForUpdate ( ) : string
Результат string

groupBy() публичный Метод

Creates and adds a "group by" to the query.
public groupBy ( mixed $groupBy ) : self
$groupBy mixed
Результат self

guessParamTypes() защищенный Метод

Tries to guess param types
protected guessParamTypes ( array $params = [] ) : array
$params array
Результат array

having() публичный Метод

Creates and adds a "having" to the query.
public having ( mixed $having, string $type = CompositeExpression::TYPE_AND ) : self
$having mixed
$type string
Результат self

innerJoin() публичный Метод

Creates and adds an "inner join" to the query.
public innerJoin ( string $table, string $condition = null ) : self
$table string
$condition string
Результат self

join() публичный Метод

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
Результат self

leftJoin() публичный Метод

Creates and adds a "left join" to the query.
public leftJoin ( string $table, string $condition = null ) : self
$table string
$condition string
Результат self

limit() публичный Метод

Sets the limit of the query.
public limit ( integer $limit ) : self
$limit integer
Результат self

max() публичный Метод

Execute the query and get the "max" result.
public max ( string $column ) : mixed
$column string
Результат mixed

min() публичный Метод

Execute the query and get the "min" result.
public min ( string $column ) : mixed
$column string
Результат mixed

newQuery() защищенный Метод

Creates a new query builder.
protected newQuery ( ) : QueryBuilder
Результат QueryBuilder

offset() публичный Метод

Sets the offset of the query.
public offset ( integer $offset ) : self
$offset integer
Результат self

orHaving() публичный Метод

Creates and adds a "or having" to the query.
public orHaving ( mixed $having ) : self
$having mixed
Результат self

orWhere() публичный Метод

Creates and adds a "or where" to the query.
public orWhere ( mixed $condition, array $params = [] ) : self
$condition mixed
$params array
Результат self

orWhereExists() публичный Метод

Creates and adds a "or where exists" to the query.
public orWhereExists ( Closure $callback, boolean $not = false ) : self
$callback Closure
$not boolean
Результат self

orWhereIn() публичный Метод

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
Результат self

orderBy() публичный Метод

Creates and adds an "order by" to the query.
public orderBy ( string $sort, string $order = null ) : self
$sort string
$order string
Результат self

parameter() защищенный Метод

protected parameter ( $name )

params() публичный Метод

Get or set multiple query parameters.
public params ( array $params = null ) : array | self
$params array
Результат array | self

rightJoin() публичный Метод

Creates and adds a "right join" to the query.
public rightJoin ( string $table, string $condition = null ) : self
$table string
$condition string
Результат self

select() публичный Метод

Creates and adds a "select" to the query.
public select ( mixed $columns = ['*'] ) : self
$columns mixed
Результат self

setPart() публичный Метод

Sets a query part and replaces all previous values.
public setPart ( string $name, mixed $parts ) : self
$name string
$parts mixed
Результат self

sum() публичный Метод

Execute the query and get the "sum" result.
public sum ( string $column ) : mixed
$column string
Результат mixed

update() публичный Метод

Execute the "update" query with the given values.
public update ( array $values ) : integer
$values array
Результат integer

where() публичный Метод

Creates and adds a "where" to the query.
public where ( mixed $condition, array $params = [] ) : self
$condition mixed
$params array
Результат self

whereExists() публичный Метод

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
Результат self

whereIn() публичный Метод

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
Результат self

whereInSet() публичный Метод

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
Результат self

Описание свойств

$connection защищенное свойство

The Connection.
protected Connection,Pagekit\Database $connection
Результат Pagekit\Database\Connection

$params защищенное свойство

The query parameters.
protected array $params
Результат array

$parts защищенное свойство

The query parts.
protected array $parts
Результат array