com\setasign\SetaFramework\Database\Query

Update Class Query Update

File: /SetaFramework/src/Database/Query/Update.php

Class hierarchy

Implements

Summary

Properties

$parts

protected array AbstractQuery::$parts = array()

Contains the single parts of the statement


Methods

__construct()

public Update::__construct (
?string $tableName = null
)

Constructor

Parameters
$tableName : ?string
 

addFilter()

protected AbstractQuery::addFilter (
array &$part,
string $logic,
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Add a filter to a specific part

$statementOrColumn can be a Closure if $operator isn't set. The Closure will be called with (AbstractQuery $query, Database $quoteInterface) and has no return. $query won't be inserted directly, only the added parts of type $part will be used and set in parentheses.

Parameters
$part : array
 
$logic : string

Logic operator like "OR" or "AND" or "XOR", not important if this is the first element of a part

$statementOrColumn : string|\Closure
 
$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as a value.

addOn()

protected AbstractQuery::addOn (
string $logic,
string|\Closure $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a on-block to last added join

Parameters
$logic : string

Logic operator like "OR" or "AND", not important if this is the first element of a part

$statementOrColumn : string|\Closure
 
$operator : ?string
 
$compareValue : mixed
 
Exceptions

Throws \BadMethodCallException

getPart()

public AbstractQuery::getPart (
string $part
): ?mixed

Returns the defined part

Parameters
$part : string
 

getSql()

Returns the query as a string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlFrom()

Parses the from-block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlJoin()

Parses the join block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlLimit()

Parses the limit block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlOrderBy()

Parses the orderBy block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlSet()

Parses the set-block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlWhere()

Parses the where block to string

Parameters
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 

getSqlWith()

hasPart()

public AbstractQuery::hasPart (
string $part
): bool
Parameters
$part : string
 

join()

public AbstractQuery::join (
string|array|Select|\Closure $table,
string $joinType = '',
IndexHintList|IndexHintList[] $indexHintList = array ( )
): static

Adds a join to query

Parameters
$table : string|array|Select|\Closure

By default, this will be quoted as an identifier.

$joinType : string
 
$indexHintList : IndexHintList|IndexHintList[]
 

joinInner()

public AbstractQuery::joinInner (
string|array|Select|\Closure $table,
IndexHintList|IndexHintList[] $indexHintList = array ( )
): static

Adds an inner-join to query

Parameters
$table : string|array|Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : IndexHintList|IndexHintList[]
 

joinLeft()

public AbstractQuery::joinLeft (
string|array|Select|\Closure $table,
IndexHintList|IndexHintList[] $indexHintList = array ( )
): static

Adds a left-outer-join to query

Parameters
$table : string|array|Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : IndexHintList|IndexHintList[]
 

joinRight()

public AbstractQuery::joinRight (
string|array|Select|\Closure $table,
IndexHintList|IndexHintList[] $indexHintList = array ( )
): static

Adds a right-outer-join to query

Parameters
$table : string|array|Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : IndexHintList|IndexHintList[]
 

joinStraight()

public AbstractQuery::joinStraight (
string|array|Select|\Closure $table,
IndexHintList|IndexHintList[] $indexHintList = array ( )
): static

Adds a straight-join to query

Parameters
$table : string|array|Select|\Closure

By default, this will be quoted as an identifier.

$indexHintList : IndexHintList|IndexHintList[]
 

limit()

public AbstractQuery::limit (
int $limit
): static

Sets a limit for query

Parameters
$limit : int
 

on()

public AbstractQuery::on (
string|array|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a ON-AND-condition to last added join

Parameters
$statementOrColumn : string|array|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, this will be quoted as an identifier.

$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as an identifier.

Exceptions

Throws \BadMethodCallException

onOr()

public AbstractQuery::onOr (
string|array|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
?string $compareValue = null
): static

Adds a ON-OR-condition to last added join

Parameters
$statementOrColumn : string|array|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, this will be quoted as an identifier.

$operator : ?string
 
$compareValue : ?string

By default, this will be quoted as an identifier.

onOrParentheseOpen()

public AbstractQuery::onOrParentheseOpen (
bool $reverse = false
): static

Starts a ON-OR-condition-block in parentheses to last added join

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

onParentheseClose()

Ends the last on-condition-block in parentheses

onParentheseOpen()

public AbstractQuery::onParentheseOpen (
bool $reverse = false
): static

Starts a ON-AND-condition-block in parentheses to last added join

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

orderBy()

Adds an order-by-column to query

Parameters
$column : string|Select|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, quoted as an identifier.

$direction : string

'ASC' or 'DESC'

processFilter()

protected AbstractQuery::processFilter (
array $parts,
\com\setasign\SetaFramework\Database\QuoteInterface $quoteInterface,
string $mainPart
): string

Parses a single part to string

Parameters
$parts : array
 
$quoteInterface : \com\setasign\SetaFramework\Database\QuoteInterface
 
$mainPart : string
 
Exceptions

Throws \InvalidArgumentException

reset()

public AbstractQuery::reset (
?string $part = null
): static

Resets a single part or all parts of the statement

Parameters
$part : ?string
 

set()

public Update::set (
array|string $columnOrValues,
null|string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $value = null
): static

Sets the set-block

If $columnOrValues is an array, the old set-block will be completely overwritten and $value will be ignored.

Otherwise, $columnOrValues will be added as column with value $value to actual set-block

Parameters
$columnOrValues : array|string
 
$value : null|string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

Will be quoted as value.

table()

public Update::table (
string $tableName
): static

Sets the table which should be updated

Parameters
$tableName : string
 

where()

public AbstractQuery::where (
string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a WHERE-AND-condition to where part

Parameters
$statementOrColumn : string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, quoted as an identifier.

$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as a value.

whereOr()

public AbstractQuery::whereOr (
string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a WHERE-OR-condition to where part

Parameters
$statementOrColumn : string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, quoted as an identifier.

$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as a value.

whereOrParentheseOpen()

public AbstractQuery::whereOrParentheseOpen (
bool $reverse = false
): static

Starts an WHERE-OR-condition-block in parentheses

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

whereParentheseClose()

Ends the last condition-block in parentheses

whereParentheseOpen()

public AbstractQuery::whereParentheseOpen (
bool $reverse = false
): static

Starts an WHERE-AND-condition-block in parentheses

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

whereXor()

public AbstractQuery::whereXor (
string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface $statementOrColumn,
?string $operator = null,
mixed $compareValue = null
): static

Adds a WHERE-XOR-condition to where part

Parameters
$statementOrColumn : string|int|\Closure|\com\setasign\SetaFramework\Database\ExpressionInterface

By default, quoted as an identifier.

$operator : ?string
 
$compareValue : mixed

By default, this will be quoted as a value.

whereXorParentheseOpen()

public AbstractQuery::whereXorParentheseOpen (
bool $reverse = false
): static

Starts an WHERE-XOR-condition-block in parentheses

There is no autoclosing of parentheses.

Parameters
$reverse : bool

Reverse result of parenthese with prefix NOT

with()

public AbstractQuery::with (
string $name,
Select|Union|\Closure|string $query
): static
Parameters
$name : string
 
$query : Select|Union|\Closure|string
 

withRecursive()

public AbstractQuery::withRecursive (
string $name,
Select|Union|\Closure|string $query
): static
Parameters
$name : string
 
$query : Select|Union|\Closure|string