PHP Класс Bluz\Db\Query\Select

Наследование: extends AbstractBuilder, use trait Bluz\Db\Query\Traits\From, use trait Bluz\Db\Query\Traits\Where, use trait Bluz\Db\Query\Traits\Order, use trait Bluz\Db\Query\Traits\Limit
Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$fetchType PDO fetch types or object class

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

Метод Описание
addGroupBy ( variadic $groupBy ) : Select Adds a grouping expression to the query.
addSelect ( string $select ) : Select Adds an item that is to be returned in the query result.
andHaving ( variadic $condition ) : Select Adds a restriction over the groups of the query, forming a logical conjunction with any existing having restrictions
execute ( integer | string | object $fetchType = null ) : integer | string | array
getSql ( ) : string
groupBy ( variadic $groupBy ) : Select Specifies a grouping over the results of the query.
having ( variadic $condition ) : Select Specifies a restriction over the groups of the query.
innerJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select Creates and adds a join to the query
join ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select Creates and adds a join to the query
leftJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select Creates and adds a left join to the query.
orHaving ( variadic $condition ) : Select Adds a restriction over the groups of the query, forming a logical disjunction with any existing having restrictions
rightJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select Creates and adds a right join to the query.
select ( variadic $select ) : Select Specifies an item that is to be returned in the query result Replaces any previously specified selections, if any
setFetchType ( string $fetchType ) : Select Setup fetch type, any of PDO, or any Class
setPage ( integer $page = 1 ) : Select Setup offset like a page number, start from 1

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

Метод Описание
getSQLForJoins ( string $fromAlias ) : string Generate SQL string for JOINs

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

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

Example $sb = new Select(); $sb ->select('u.name') ->from('users', 'u') ->groupBy('u.lastLogin'); ->addGroupBy('u.createdAt')
public addGroupBy ( variadic $groupBy ) : Select
$groupBy variadic the grouping expression
Результат Select instance

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

Example $sb = new Select(); $sb ->select('u.id') ->addSelect('p.id') ->from('users', 'u') ->leftJoin('u', 'phone', 'u.id = p.user_id');
public addSelect ( string $select ) : Select
$select string the selection expression
Результат Select instance

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

Adds a restriction over the groups of the query, forming a logical conjunction with any existing having restrictions
public andHaving ( variadic $condition ) : Select
$condition variadic the query restriction predicates
Результат Select

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

public execute ( integer | string | object $fetchType = null ) : integer | string | array
$fetchType integer | string | object
Результат integer | string | array

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

Generate SQL string for JOINs
protected getSQLForJoins ( string $fromAlias ) : string
$fromAlias string alias of table
Результат string

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

public getSql ( ) : string
Результат string

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

Replaces any previously specified groupings, if any. Example $sb = new Select(); $sb ->select('u.name') ->from('users', 'u') ->groupBy('u.id');
public groupBy ( variadic $groupBy ) : Select
$groupBy variadic the grouping expression
Результат Select instance

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

Replaces any previous having restrictions, if any
public having ( variadic $condition ) : Select
$condition variadic the query restriction predicates
Результат Select

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

Example $sb = new Select(); $sb ->select('u.name') ->from('users', 'u') ->innerJoin('u', 'phone', 'p', 'p.is_primary = 1');
public innerJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select
$fromAlias string the alias that points to a from clause
$join string the table name to join
$alias string the alias of the join table
$condition string the condition for the join
Результат Select instance

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

Example $sb = new Select(); $sb ->select('u.name') ->from('users', 'u') ->join('u', 'phone', 'p', 'p.is_primary = 1');
public join ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select
$fromAlias string the alias that points to a from clause
$join string the table name to join
$alias string the alias of the join table
$condition string the condition for the join
Результат Select instance

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

Example $sb = new Select(); $sb ->select('u.name') ->from('users', 'u') ->leftJoin('u', 'phone', 'p', 'p.is_primary = 1');
public leftJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select
$fromAlias string the alias that points to a from clause
$join string the table name to join
$alias string the alias of the join table
$condition string the condition for the join
Результат Select instance

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

Adds a restriction over the groups of the query, forming a logical disjunction with any existing having restrictions
public orHaving ( variadic $condition ) : Select
$condition variadic the query restriction predicates
Результат Select

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

Example $sb = new Select(); $sb ->select('u.name') ->from('users', 'u') ->rightJoin('u', 'phone', 'p', 'p.is_primary = 1');
public rightJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : Select
$fromAlias string the alias that points to a from clause
$join string the table name to join
$alias string the alias of the join table
$condition string the condition for the join
Результат Select instance

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

Example $sb = new Select(); $sb ->select('u.id', 'p.id') ->from('users', 'u') ->leftJoin('u', 'phone', 'p', 'u.id = p.user_id');
public select ( variadic $select ) : Select
$select variadic the selection expressions
Результат Select instance

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

Setup fetch type, any of PDO, or any Class
public setFetchType ( string $fetchType ) : Select
$fetchType string
Результат Select instance

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

Setup offset like a page number, start from 1
public setPage ( integer $page = 1 ) : Select
$page integer
Результат Select

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

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

PDO fetch types or object class
protected $fetchType