just another orm...
View the Project on GitHub tflori/orm
» API Reference » ORM\QueryBuilder\QueryBuilderInterface
Extends: ORM\QueryBuilder\ParenthesisInterface
Name | Value |
---|---|
DIRECTION_ASCENDING | 'ASC' |
DIRECTION_DESCENDING | 'DESC' |
public function andParenthesis(): $this
Returns | $this |
ORM\QueryBuilder\QueryBuilderInterface::andParenthesis
public function andWhere(
string $column,
string|array $operator = '',
string $value = '',
): $this
QueryBuilderInterface andWhere($column[, $operator[, $value]]);
If $column has the same amount of question marks as $value - $value is the second parameter.
If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.
These calls are equal:
$query->andWhere('name', '=' , 'John Doe');
$query->andWhere('name = ?', 'John Doe');
$query->andWhere('name', 'John Doe');
$query->andWhere('name = ?', ['John Doe']);
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$column |
string | Column or expression with placeholders | |
$operator |
**string | array** | Operator, value or array of values |
$value |
string | Value (required when used with operator) |
ORM\QueryBuilder\QueryBuilderInterface::andWhere
public function close(
,
): \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
Returns | ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface |
ORM\QueryBuilder\QueryBuilderInterface::close
public function column(
string $column,
array $args = [],
string $alias = '',
): $this
Optionally you can provide an expression with question marks as placeholders filled with $args.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression to fetch |
$args |
array | Arguments for expression |
$alias |
string | Alias for the column |
ORM\QueryBuilder\QueryBuilderInterface::column
public function columns(array|null $columns = null): $this
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$columns |
**array | null** |
ORM\QueryBuilder\QueryBuilderInterface::columns
public function fullJoin(
string $tableName,
string|bool $expression = '',
string $alias = '',
array $args = [],
): $this|\ORM\QueryBuilder\ParenthesisInterface
When no expression got provided self get returned. If you want to get a parenthesis the parameter empty can be set to false.
ATTENTION: here the default value of empty got changed - defaults to yes
Returns | $this|ORM\QueryBuilder\ParenthesisInterface |
Parameter | Type | Description | |
---|---|---|---|
$tableName |
string | Table to join | |
$expression |
**string | bool** | Expression, single column name or boolean to create an empty join |
$alias |
string | Alias for the table | |
$args |
array | Arguments for expression |
ORM\QueryBuilder\QueryBuilderInterface::fullJoin
public function getExpression(): string
Returns the complete expression inside this parenthesis.
Returns | string |
ORM\QueryBuilder\QueryBuilderInterface::getExpression
public function getQuery(): string
Builds the statement from current where conditions, joins, columns and so on.
Returns | string |
ORM\QueryBuilder\QueryBuilderInterface::getQuery
public function groupBy(string $column, array $args = []): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for groups |
$args |
array | Arguments for expression |
ORM\QueryBuilder\QueryBuilderInterface::groupBy
public function join(
string $tableName,
string|bool $expression = '',
string $alias = '',
array $args = [],
): $this|\ORM\QueryBuilder\ParenthesisInterface
When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.
Returns | $this|ORM\QueryBuilder\ParenthesisInterface |
Parameter | Type | Description | |
---|---|---|---|
$tableName |
string | Table to join | |
$expression |
**string | bool** | Expression, single column name or boolean to create an empty join |
$alias |
string | Alias for the table | |
$args |
array | Arguments for expression |
ORM\QueryBuilder\QueryBuilderInterface::join
public function leftJoin(
string $tableName,
string|bool $expression = '',
string $alias = '',
array $args = [],
): $this|\ORM\QueryBuilder\ParenthesisInterface
When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.
Returns | $this|ORM\QueryBuilder\ParenthesisInterface |
Parameter | Type | Description | |
---|---|---|---|
$tableName |
string | Table to join | |
$expression |
**string | bool** | Expression, single column name or boolean to create an empty join |
$alias |
string | Alias for the table | |
$args |
array | Arguments for expression |
ORM\QueryBuilder\QueryBuilderInterface::leftJoin
public function limit(int $limit): $this
Limits the amount of rows fetched from database.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$limit |
int | The limit to set |
ORM\QueryBuilder\QueryBuilderInterface::limit
public function modifier(string $modifier): $this
Add query modifiers such as SQL_CALC_FOUND_ROWS or DISTINCT.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$modifier |
string |
ORM\QueryBuilder\QueryBuilderInterface::modifier
public function offset(int $offset): $this
Changes the offset (only with limit) where fetching starts in the query.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$offset |
int | The offset to set |
ORM\QueryBuilder\QueryBuilderInterface::offset
public function orderBy(
string $column,
string $direction = self::DIRECTION_ASCENDING,
array $args = [],
): $this
Optionally you can provide an expression in $column with question marks as placeholders.
Returns | $this |
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression for order |
$direction |
string | Direction (default: ASC ) |
$args |
array | Arguments for expression |
ORM\QueryBuilder\QueryBuilderInterface::orderBy
public function orParenthesis(): $this
Returns | $this |
ORM\QueryBuilder\QueryBuilderInterface::orParenthesis
public function orWhere(
string $column,
string|array $operator = '',
string $value = '',
): $this
QueryBuilderInterface orWhere($column[, $operator[, $value]]);
If $column has the same amount of question marks as $value - $value is the second parameter.
If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.
These calls are equal:
$query->orWhere('name', '=' , 'John Doe');
$query->orWhere('name = ?', 'John Doe');
$query->orWhere('name', 'John Doe');
$query->orWhere('name = ?', ['John Doe']);
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$column |
string | Column or expression with placeholders | |
$operator |
**string | array** | Operator, value or array of values |
$value |
string | Value (required when used with operator) |
ORM\QueryBuilder\QueryBuilderInterface::orWhere
public function orWhereIn(string|array $column, array $values): $this
If $column is an array a composite where in statement will be created
Example:
whereIn(['a', 'b'], [[42, 23], [42, 23]])
gets (a,b) IN ((42,23), (23,42))
in mysql
If $values is empty the expression will be 1 = 0
because an empty parenthesis causes an error in SQL.
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$column |
**string | array** | |
$values |
array |
ORM\QueryBuilder\QueryBuilderInterface::orWhereIn
public function orWhereNotIn(string|array $column, array $values): $this
If $column is an array a composite where in statement will be created
Example:
whereIn(['a', 'b'], [[42, 23], [42, 23]])
gets (a,b) NOT IN ((42,23), (23,42))
in mysql
If $values is empty the expression will be 1 = 1
because an empty parenthesis causes an error in SQL.
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$column |
**string | array** | |
$values |
array |
ORM\QueryBuilder\QueryBuilderInterface::orWhereNotIn
public function parenthesis(): $this
Returns | $this |
See Also:
ORM\QueryBuilder\QueryBuilderInterface::parenthesis
public function rightJoin(
string $tableName,
string|bool $expression = '',
string $alias = '',
array $args = [],
): $this|\ORM\QueryBuilder\ParenthesisInterface
When no expression got provided a ParenthesisInterface get returned. If this parenthesis not get filled you will most likely get an error from your database. If you don’t want to get a parenthesis the parameter empty can be set to true.
Returns | $this|ORM\QueryBuilder\ParenthesisInterface |
Parameter | Type | Description | |
---|---|---|---|
$tableName |
string | Table to join | |
$expression |
**string | bool** | Expression, single column name or boolean to create an empty join |
$alias |
string | Alias for the table | |
$args |
array | Arguments for expression |
ORM\QueryBuilder\QueryBuilderInterface::rightJoin
public function where(
string $column,
mixed $operator = '',
mixed $value = '',
): $this
QueryBuilderInterface where($column[, $operator[, $value]]);
If $column has the same amount of question marks as $value - $value is the second parameter.
If there is no third parameter and no question mark in $column then the default operator is ‘=’ and $value is the second parameter.
These calls are equal:
$query->where('name', '=' , 'John Doe');
$query->where('name = ?', 'John Doe');
$query->where('name', 'John Doe');
$query->where('name = ?', ['John Doe']);
Returns | $this |
Parameter | Type | Description |
---|---|---|
$column |
string | Column or expression with placeholders |
$operator |
mixed | Operator, value or array of values |
$value |
mixed | Value (required when used with operator) |
See Also:
ORM\QueryBuilder\QueryBuilderInterface::where
public function whereIn(string|array $column, array $values): $this
If $column is an array a composite where in statement will be created
Example:
whereIn(['a', 'b'], [[42, 23], [42, 23]])
gets (a,b) IN ((42,23), (23,42))
in mysql
If $values is empty the expression will be 1 = 0
because an empty parenthesis causes an error in SQL.
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$column |
**string | array** | |
$values |
array |
ORM\QueryBuilder\QueryBuilderInterface::whereIn
public function whereNotIn(string|array $column, array $values): $this
If $column is an array a composite where in statement will be created
Example:
whereIn(['a', 'b'], [[42, 23], [42, 23]])
gets (a,b) NOT IN ((42,23), (23,42))
in mysql
If $values is empty the expression will be 1 = 1
because an empty parenthesis causes an error in SQL.
Returns | $this |
Parameter | Type | Description | |
---|---|---|---|
$column |
**string | array** | |
$values |
array |
ORM\QueryBuilder\QueryBuilderInterface::whereNotIn