PHP 클래스 Bluz\Db\Query\AbstractBuilder

파일 보기 프로젝트 열기: bluzphp/framework

보호된 프로퍼티들

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

공개 메소드들

메소드 설명
__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

보호된 메소드들

메소드 설명
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

메소드 상세

__toString() 공개 메소드

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

addQueryPart() 보호된 메소드

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() 공개 메소드

Execute this query using the bound parameters and their types
public execute ( ) : integer | string | array
리턴 integer | string | array

getParameter() 공개 메소드

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
리턴 mixed The value of the bound parameter.

getParameters() 공개 메소드

Gets all defined query parameters for the query being constructed
public getParameters ( ) : array
리턴 array The currently defined query parameters

getQuery() 공개 메소드

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
리턴 string

getQueryPart() 공개 메소드

Get a query part by its name
public getQueryPart ( string $queryPartName ) : mixed
$queryPartName string
리턴 mixed

getSql() 추상적인 공개 메소드

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

prepareCondition() 보호된 메소드

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

resetQueryPart() 보호된 메소드

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

setFromQueryPart() 보호된 메소드

setFromQueryPart
protected setFromQueryPart ( string $table )
$table string

setParameter() 공개 메소드

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() 공개 메소드

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

프로퍼티 상세

$aliases 보호되어 있는 프로퍼티

list of table aliases
protected $aliases

$params 보호되어 있는 프로퍼티

the query parameters
protected $params

$sql 보호되어 있는 프로퍼티

the complete SQL string for this query
protected $sql

$sqlParts 보호되어 있는 프로퍼티

the array of SQL parts collected
protected $sqlParts

$types 보호되어 있는 프로퍼티

the parameter type map of this query
protected $types