An expression object to contain values being inserted.
Helps generate SQL with the correct number of placeholders and bind values correctly into the statement.
bool
Whether or not values have been casted to expressions already.
array
List of columns to ensure are part of the insert.
\Cake\Database\Query|null
The Query object to use as a values expression
\Cake\Database\TypeMap
array
Array of values to insert.
Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.
Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.
Gets the query object to be used as the values expression to be evaluated to insert records in the table.
Sets the query object to be used as the values expression to be evaluated to insert records in the table.
Creates a new TypeMap if $typeMap is an array, otherwise exchanges it for the given one.
__construct(array $columns, \Cake\Database\TypeMap $typeMap)
Constructor
array
$columns The list of columns that are going to be part of the values.
\Cake\Database\TypeMap
$typeMap A dictionary of column -> type names
_castToExpression(mixed $value, ?string $type)
Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.
mixed
$value The value to converto to ExpressionInterface
string|null
$type optional The type name
mixed
_columnNames()
Get the bare column names.
Because column names could be identifier quoted, we need to strip the identifiers off of the columns.
array
_processExpressions()
Converts values that need to be casted to expressions
_requiresToExpressionCasting(array $types)
Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.
array
$types List of type names
array
add(mixed $data)
Add a row of data to be inserted.
array|\Cake\Database\Query
$data Array of data to append into the insert, or a query for doing INSERT INTO .. SELECT style commands
Cake\Database\Exception
getColumns()
Gets the columns to be inserted.
array
getDefaultTypes()
Gets default types of current type map.
array
getQuery()
Gets the query object to be used as the values expression to be evaluated to insert records in the table.
\Cake\Database\Query|null
getTypeMap()
Returns the existing type map.
\Cake\Database\TypeMap
getValues()
Gets the values to be inserted.
array
setColumns(array $cols)
Sets the columns to be inserted.
array
$cols Array with columns to be inserted.
$this
setDefaultTypes(array $types)
Overwrite the default type mappings for fields in the implementing object.
This method is useful if you need to set type mappings that are shared across multiple functions/expressions in a query.
To add a default without overwriting existing ones use getTypeMap()->addDefaults()
array
$types The array of types to set.
$this
setQuery(\Cake\Database\Query $query)
Sets the query object to be used as the values expression to be evaluated to insert records in the table.
\Cake\Database\Query
$query The query to set
$this
setTypeMap(mixed $typeMap)
Creates a new TypeMap if $typeMap is an array, otherwise exchanges it for the given one.
array|\Cake\Database\TypeMap
$typeMap Creates a TypeMap if array, otherwise sets the given TypeMap
$this
setValues(array $values)
Sets the values to be inserted.
array
$values Array with values to be inserted.
$this
sql(\Cake\Database\ValueBinder $generator)
Convert the values into a SQL string with placeholders.
\Cake\Database\ValueBinder
$generator Placeholder generator object
string
traverse(\Closure $visitor)
Traverse the values expression.
This method will also traverse any queries that are to be used in the INSERT values.
\Closure
$visitor The visitor to traverse the expression with.
$this
Whether or not values have been casted to expressions already.
bool
List of columns to ensure are part of the insert.
array
The Query object to use as a values expression
\Cake\Database\Query|null
\Cake\Database\TypeMap
Array of values to insert.
array
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.Database.Expression.ValuesExpression.html