PHP 클래스 Pagekit\Database\Query\QueryBuilder

파일 보기 프로젝트 열기: pagekit/pagekit 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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