Aplus Framework Docs

Replace extends Statement
in package
Uses Select, Set, Values

Class Replace.

Tags
see
https://mariadb.com/kb/en/replace/

Table of Contents

OPT_DELAYED  = 'DELAYED'
OPT_LOW_PRIORITY  = 'LOW_PRIORITY'
$database  : Database
$sql  : array<string|int, mixed>
SQL clauses and parts.
__construct()  : mixed
Statement constructor.
__toString()  : string
columns()  : static
into()  : static
options()  : static
Sets the statement options.
reset()  : static
Resets SQL clauses and parts.
run()  : int|string
Runs the REPLACE statement.
select()  : static
Sets the SELECT statement part.
set()  : static
Sets the SET clause.
sql()  : string
Renders the REPLACE statement.
values()  : static
Adds a row of values to the VALUES clause.
checkRowStatementsConflict()  : void
hasOptions()  : bool
Tells if the statement has options set.
hasSet()  : bool
Tells if the SET clause was set.
renderAliasedIdentifier()  : string
Renders a column part with an optional alias name, AS clause.
renderAssignment()  : string
Renders an assignment part.
renderColumns()  : string|null
renderIdentifier()  : string
Renders a column part.
renderInto()  : string
renderLimit()  : string|null
Renders the LIMIT clause.
renderOptions()  : string|null
renderSelect()  : string|null
renderSet()  : string|null
Renders the SET clause.
renderSetCheckingConflicts()  : string|null
Renders the SET clause checking conflicts.
renderValue()  : float|int|string
Renders a subquery or quote a value.
renderValues()  : string|null
Renders the VALUES clause.
setLimit()  : static
Sets the LIMIT clause.
subquery()  : string
Returns an SQL part between parentheses.

Constants

Properties

$sql

SQL clauses and parts.

protected array<string|int, mixed> $sql = []

Methods

__construct()

Statement constructor.

public __construct(Database $database) : mixed
Parameters
$database : Database
Return values
mixed

__toString()

public __toString() : string
Return values
string

columns()

public columns(string $column, string ...$columns) : static
Parameters
$column : string
$columns : string
Return values
static

into()

public into(string $table) : static
Parameters
$table : string
Return values
static

options()

Sets the statement options.

public options(string $option, string ...$options) : static
Parameters
$option : string

One of the OPT_* constants

$options : string

Each option value must be one of the OPT_* constants

Return values
static

reset()

Resets SQL clauses and parts.

public reset([string|null $sql = null ]) : static
Parameters
$sql : string|null = null

A part name or null to reset all

Tags
see
Statement::$sql
Return values
static

run()

Runs the REPLACE statement.

public run() : int|string
Return values
int|string

The number of affected rows

set()

Sets the SET clause.

public set(array<string, \Closure|float|int|string|null>|object $columns) : static
Parameters
$columns : array<string, \Closure|float|int|string|null>|object

Array of columns => values or an object to be cast to array

Return values
static

sql()

Renders the REPLACE statement.

public sql() : string
Return values
string

values()

Adds a row of values to the VALUES clause.

public values(array<string|int, array<string|int, mixed>>|Closure|float|int|string|null $value, Closure|float|int|string|null ...$values) : static
Parameters
$value : array<string|int, array<string|int, mixed>>|Closure|float|int|string|null
$values : Closure|float|int|string|null
Return values
static

checkRowStatementsConflict()

protected checkRowStatementsConflict() : void
Return values
void

hasOptions()

Tells if the statement has options set.

protected hasOptions() : bool
Return values
bool

hasSet()

Tells if the SET clause was set.

protected hasSet() : bool
Return values
bool

True if was set, otherwise false

renderAliasedIdentifier()

Renders a column part with an optional alias name, AS clause.

protected renderAliasedIdentifier(array<string, \Closure|string>|Closure|string $column) : string
Parameters
$column : array<string, \Closure|string>|Closure|string

The column name, a subquery or an array where the index is the alias and the value is the column/subquery

Return values
string

renderColumns()

protected renderColumns() : string|null
Return values
string|null

renderIdentifier()

Renders a column part.

protected renderIdentifier(Closure|string $column) : string
Parameters
$column : Closure|string

The column name or a subquery

Return values
string

renderInto()

protected renderInto() : string
Return values
string

renderLimit()

Renders the LIMIT clause.

protected renderLimit() : string|null
Return values
string|null

renderOptions()

protected renderOptions() : string|null
Return values
string|null

renderSelect()

protected renderSelect() : string|null
Return values
string|null

renderSet()

Renders the SET clause.

protected renderSet() : string|null
Return values
string|null

The SET clause null if it was not set

renderSetCheckingConflicts()

Renders the SET clause checking conflicts.

protected renderSetCheckingConflicts() : string|null
Tags
throws
LogicException

if SET was set with columns or with the VALUES clause

Return values
string|null

The SET part or null if it was not set

renderValue()

Renders a subquery or quote a value.

protected renderValue(Closure|float|int|string|null $value) : float|int|string
Parameters
$value : Closure|float|int|string|null

A Closure for subquery, other types to quote

Return values
float|int|string

renderValues()

Renders the VALUES clause.

protected renderValues() : string|null
Return values
string|null

The VALUES part or null if none was set

setLimit()

Sets the LIMIT clause.

protected setLimit(int $limit[, int|null $offset = null ]) : static
Parameters
$limit : int
$offset : int|null = null
Tags
see
https://mariadb.com/kb/en/limit/
Return values
static

Search results