SQLWriteExpression
interface SQLWriteExpression (View source)
Represents a SQL expression which may have field values assigned (UPDATE/INSERT Expressions)
Methods
Adds assignments for a list of several fields.
Sets the list of assignments to the given list
Retrieves the list of assignments in parameterised format
Set the value for a single field
Assigns a value to a field using the literal SQL expression, rather than a value to be escaped
Details
$this
addAssignments(array $assignments)
Adds assignments for a list of several fields.
For multi-row objects this applies this to the current row.
Note that field values must not be escaped, as these will be internally parameterised by the database engine.
// Basic assignments $query->addAssignments([ '"Object"."Title"' => 'Bob', '"Object"."Description"' => 'Bob was here' ])
// Parameterised assignments $query->addAssignments([ '"Object"."Title"' => ['?' => 'Bob'], '"Object"."Description"' => ['?' => null] ])
// Complex parameters $query->addAssignments([ '"Object"."Score"' => ['MAX(?,?)' => [1, 3]] ]);
// Assignment of literal SQL for a field. The empty array is // important to denote the zero-number parameter list $query->addAssignments([ '"Object"."Score"' => ['NOW()' => []] ]);
$this
setAssignments(array $assignments)
Sets the list of assignments to the given list
For multi-row objects this applies this to the current row.
array
getAssignments()
Retrieves the list of assignments in parameterised format
For multi-row objects returns assignments for the current row.
$this
assign(string $field, mixed $value)
Set the value for a single field
For multi-row objects this applies this to the current row.
E.g.
// Literal assignment $query->assign('"Object"."Description"', 'lorum ipsum'));
// Single parameter $query->assign('"Object"."Title"', ['?' => 'Bob']);
// Complex parameters $query->assign('"Object"."Score"', ['MAX(?,?)' => [1, 3]]);
$this
assignSQL(string $field, string $sql)
Assigns a value to a field using the literal SQL expression, rather than a value to be escaped
For multi-row objects this applies this to the current row.