Property | Type | Description | |
---|---|---|---|
$fetchType | PDO fetch types or object class |
Method | Description | |
---|---|---|
addGroupBy ( variadic |
Adds a grouping expression to the query. | |
addSelect ( string $select ) : |
Adds an item that is to be returned in the query result. | |
andHaving ( variadic |
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 |
Specifies a grouping over the results of the query. | |
having ( variadic |
Specifies a restriction over the groups of the query. | |
innerJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : |
Creates and adds a join to the query | |
join ( string $fromAlias, string $join, string $alias, string $condition = null ) : |
Creates and adds a join to the query | |
leftJoin ( string $fromAlias, string $join, string $alias, string $condition = null ) : |
Creates and adds a left join to the query. | |
orHaving ( variadic |
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 ) : |
Creates and adds a right join to the query. | |
select ( variadic |
Specifies an item that is to be returned in the query result Replaces any previously specified selections, if any | |
setFetchType ( string $fetchType ) : |
Setup fetch type, any of PDO, or any Class | |
setPage ( integer $page = 1 ) : |
Setup offset like a page number, start from 1 |
Method | Description | |
---|---|---|
getSQLForJoins ( string $fromAlias ) : string | Generate SQL string for JOINs |
$sb = new Select();
$sb
->select('u.name')
->from('users', 'u')
->groupBy('u.lastLogin');
->addGroupBy('u.createdAt')
public addGroupBy ( variadic |
||
$groupBy | variadic |
the grouping expression |
return | instance |
$sb = new Select();
$sb
->select('u.id')
->addSelect('p.id')
->from('users', 'u')
->leftJoin('u', 'phone', 'u.id = p.user_id');
public andHaving ( variadic |
||
$condition | variadic |
the query restriction predicates |
return |
protected getSQLForJoins ( string $fromAlias ) : string | ||
$fromAlias | string | alias of table |
return | string |
$sb = new Select();
$sb
->select('u.name')
->from('users', 'u')
->groupBy('u.id');
public groupBy ( variadic |
||
$groupBy | variadic |
the grouping expression |
return | instance |
public having ( variadic |
||
$condition | variadic |
the query restriction predicates |
return |
$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 ) : |
||
$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 |
return | instance |
$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 ) : |
||
$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 |
return | instance |
$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 ) : |
||
$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 |
return | instance |
public orHaving ( variadic |
||
$condition | variadic |
the query restriction predicates |
return |
$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 ) : |
||
$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 |
return | instance |
$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 | variadic |
the selection expressions |
return | instance |
public setFetchType ( string $fetchType ) : |
||
$fetchType | string | |
return | instance |