tflori/orm

just another orm...

View the Project on GitHub tflori/orm

Build Status Test Coverage Maintainability Latest Stable Version Total Downloads

» API Reference » ORM\QueryBuilder\Parenthesis

ORM\QueryBuilder\Parenthesis

Table of Contents

Abstract

Implements: ORM\QueryBuilder\ParenthesisInterface

Methods

ORM\QueryBuilder\Parenthesis::__construct

public function __construct(
    callable $onClose, 
    \ORM\QueryBuilder\ParenthesisInterface $parent, 
)
Constructor

Create a parenthesis inside another parenthesis or a query.

Parameters
Parameter Type Description
$onClose callable Callable that gets executed when the parenthesis get closed
$parent ORM\QueryBuilder\ParenthesisInterface Parent where createWhereCondition get executed

ORM\QueryBuilder\Parenthesis::__construct

↑ top


ORM\QueryBuilder\Parenthesis::andParenthesis

public function andParenthesis(): $this
Add a parenthesis with AND
Returns $this  

ORM\QueryBuilder\Parenthesis::andParenthesis

↑ top


ORM\QueryBuilder\Parenthesis::andWhere

public function andWhere(
    string $column, 
    string|array $operator = null, 
    string $value = null, 
): $this
Add a where condition with AND.

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  
Parameters
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\Parenthesis::andWhere

↑ top


ORM\QueryBuilder\Parenthesis::close

public function close(
    , 
): \ORM\QueryBuilder\QueryBuilderInterface|\ORM\QueryBuilder\ParenthesisInterface
Close parenthesis
Returns ORM\QueryBuilder\QueryBuilderInterface|ORM\QueryBuilder\ParenthesisInterface  

ORM\QueryBuilder\Parenthesis::close

↑ top


ORM\QueryBuilder\Parenthesis::getExpression

public function getExpression(): string
Get the expression
Returns string  

ORM\QueryBuilder\Parenthesis::getExpression

↑ top


ORM\QueryBuilder\Parenthesis::orParenthesis

public function orParenthesis(): $this
Add a parenthesis with OR
Returns $this  

ORM\QueryBuilder\Parenthesis::orParenthesis

↑ top


ORM\QueryBuilder\Parenthesis::orWhere

public function orWhere(
    string $column, 
    string|array $operator = null, 
    string $value = null, 
): $this
Add a where condition with OR.

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  
Parameters
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\Parenthesis::orWhere

↑ top


ORM\QueryBuilder\Parenthesis::orWhereIn

public function orWhereIn(string|array $column, array $values): $this
Add a where in condition with OR.

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  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\QueryBuilder\Parenthesis::orWhereIn

↑ top


ORM\QueryBuilder\Parenthesis::orWhereNotIn

public function orWhereNotIn(string|array $column, array $values): $this
Add a where not in condition with OR.

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  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\QueryBuilder\Parenthesis::orWhereNotIn

↑ top


ORM\QueryBuilder\Parenthesis::parenthesis

public function parenthesis(): $this
Alias for andParenthesis
Returns $this  

ORM\QueryBuilder\Parenthesis::parenthesis

↑ top


ORM\QueryBuilder\Parenthesis::where

public function where(
    string $column, 
    mixed $operator = null, 
    mixed $value = null, 
): $this
Alias for andWhere

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  
Parameters
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\Parenthesis::where

↑ top


ORM\QueryBuilder\Parenthesis::whereIn

public function whereIn(string|array $column, array $values): $this
Add a where in condition with AND.

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  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\QueryBuilder\Parenthesis::whereIn

↑ top


ORM\QueryBuilder\Parenthesis::whereNotIn

public function whereNotIn(string|array $column, array $values): $this
Add a where not in condition with AND.

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  
Parameters
Parameter Type Description  
$column **string array**  
$values array    

ORM\QueryBuilder\Parenthesis::whereNotIn

↑ top