PHP Class Bluz\Db\Query\Select

Inheritance: 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
Afficher le fichier Open project: bluzphp/framework Class Usage Examples

Protected Properties

Свойство Type Description
$fetchType PDO fetch types or object class

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
getSQLForJoins ( string $fromAlias ) : string Generate SQL string for JOINs

Method Details

addGroupBy() public méthode

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
Résultat Select instance

addSelect() public méthode

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
Résultat Select instance

andHaving() public méthode

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
Résultat Select

execute() public méthode

public execute ( integer | string | object $fetchType = null ) : integer | string | array
$fetchType integer | string | object
Résultat integer | string | array

getSQLForJoins() protected méthode

Generate SQL string for JOINs
protected getSQLForJoins ( string $fromAlias ) : string
$fromAlias string alias of table
Résultat string

getSql() public méthode

public getSql ( ) : string
Résultat string

groupBy() public méthode

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
Résultat Select instance

having() public méthode

Replaces any previous having restrictions, if any
public having ( variadic $condition ) : Select
$condition variadic the query restriction predicates
Résultat Select

innerJoin() public méthode

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
Résultat Select instance

join() public méthode

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
Résultat Select instance

leftJoin() public méthode

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
Résultat Select instance

orHaving() public méthode

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
Résultat Select

rightJoin() public méthode

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
Résultat Select instance

select() public méthode

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
Résultat Select instance

setFetchType() public méthode

Setup fetch type, any of PDO, or any Class
public setFetchType ( string $fetchType ) : Select
$fetchType string
Résultat Select instance

setPage() public méthode

Setup offset like a page number, start from 1
public setPage ( integer $page = 1 ) : Select
$page integer
Résultat Select

Property Details

$fetchType protected_oe property

PDO fetch types or object class
protected $fetchType