class SQLAssignmentRow

Represents a list of updates / inserts made to a single row in a table

Methods

__construct(array $values = array())

Instantiate a new SQLAssignmentRow object with the given values

addAssignments(array $assignments)

Adds assignments for a list of several fields

setAssignments(array $assignments)

Sets the list of assignments to the given list

array
getAssignments()

Retrieves the list of assignments in parameterised format

assign(string $field, mixed $value)

Set the value for a single field

assignSQL(string $field, string $sql)

Assigns a value to a field using the literal SQL expression, rather than a value to be escaped

boolean
isEmpty()

Determine if this assignment is empty

array
getColumns()

Retrieves the list of columns updated

clear()

Clears all assignment values

Details

at line 34
__construct(array $values = array())

Instantiate a new SQLAssignmentRow object with the given values

Parameters

array $values

at line 126
SQLAssignmentRow addAssignments(array $assignments)

Adds assignments for a list of several fields

Note that field values must not be escaped, as these will be internally parameterised by the database engine.

// Basic assignments $query->addAssignments(array( '"Object"."Title"' => 'Bob', '"Object"."Description"' => 'Bob was here' ))

// Parameterised assignments $query->addAssignments(array( '"Object"."Title"' => array('?' => 'Bob')), '"Object"."Description"' => array('?' => null)) ))

// Complex parameters $query->addAssignments(array( '"Object"."Score"' => array('MAX(?,?)' => array(1, 3)) ));

// Assigment of literal SQL for a field. The empty array is // important to denote the zero-number paramater list $query->addAssignments(array( '"Object"."Score"' => array('NOW()' => array()) ));

Parameters

array $assignments The list of fields to assign

Return Value

SQLAssignmentRow The self reference to this row

at line 140
SQLAssignmentRow setAssignments(array $assignments)

Sets the list of assignments to the given list

Parameters

array $assignments

Return Value

SQLAssignmentRow The self reference to this row

See also

SQLWriteExpression::addAssignments() for syntax examples

at line 151
array getAssignments()

Retrieves the list of assignments in parameterised format

Return Value

array List of assigments. The key of this array will be the column to assign, and the value a parameterised array in the format array('SQL' => array(parameters));

at line 177
SQLAssignmentRow assign(string $field, mixed $value)

Set the value for a single field

E.g.

// Literal assignment $query->assign('"Object"."Description"', 'lorum ipsum');

// Single parameter $query->assign('"Object"."Title"', array('?' => 'Bob'));

// Complex parameters $query->assign('"Object"."Score"', array('MAX(?,?)' => array(1, 3));

Parameters

string $field The field name to update
mixed $value The value to assign to this field. This could be an array containing a parameterised SQL query of any number of parameters, or a single literal value.

Return Value

SQLAssignmentRow The self reference to this row

at line 189
SQLAssignmentRow assignSQL(string $field, string $sql)

Assigns a value to a field using the literal SQL expression, rather than a value to be escaped

Parameters

string $field The field name to update
string $sql The SQL to use for this update. E.g. "NOW()"

Return Value

SQLAssignmentRow The self reference to this row

at line 198
boolean isEmpty()

Determine if this assignment is empty

Return Value

boolean Flag indicating that this assignment is empty

at line 207
array getColumns()

Retrieves the list of columns updated

Return Value

array

at line 216
SQLAssignmentRow clear()

Clears all assignment values

Return Value

SQLAssignmentRow The self reference to this row