PHP Class Cake\Database\Expression\ValuesExpression

Helps generate SQL with the correct number of placeholders and bind values correctly into the statement.
Inheritance: implements Cake\Database\ExpressionInterface, use trait Cake\Database\Type\ExpressionTypeCasterTrait, use trait Cake\Database\TypeMapTrait
Exibir arquivo Open project: cakephp/cakephp

Protected Properties

Property Type Description
$_castedExpressions string Whether or not values have been casted to expressions already.
$_columns array List of columns to ensure are part of the insert.
$_query Cake\Database\Query | null The Query object to use as a values expression
$_values array Array of values to insert.

Public Methods

Method Description
__construct ( array $columns, Cake\Database\TypeMap $typeMap ) Constructor
add ( array | Query $data ) : void Add a row of data to be inserted.
columns ( array | null $cols = null ) : array | $this Sets the columns to be inserted. If no params are passed, then it returns the currently stored columns
query ( Query $query = null ) : Query | null Sets the query object to be used as the values expression to be evaluated to insert records in the table. If no params are passed, then it returns the currently stored query
sql ( ValueBinder $generator ) : string Convert the values into a SQL string with placeholders.
traverse ( callable $visitor ) : void Traverse the values expression.
values ( array | null $values = null ) : array | $this Sets the values to be inserted. If no params are passed, then it returns the currently stored values

Protected Methods

Method Description
_columnNames ( ) : array Get the bare column names.
_processExpressions ( ) : void Converts values that need to be casted to expressions

Method Details

__construct() public method

Constructor
public __construct ( array $columns, Cake\Database\TypeMap $typeMap )
$columns array The list of columns that are going to be part of the values.
$typeMap Cake\Database\TypeMap A dictionary of column -> type names

_columnNames() protected method

Because column names could be identifier quoted, we need to strip the identifiers off of the columns.
protected _columnNames ( ) : array
return array

_processExpressions() protected method

Converts values that need to be casted to expressions
protected _processExpressions ( ) : void
return void

add() public method

Add a row of data to be inserted.
public add ( array | Query $data ) : void
$data array | Cake\Database\Query Array of data to append into the insert, or a query for doing INSERT INTO .. SELECT style commands
return void

columns() public method

Sets the columns to be inserted. If no params are passed, then it returns the currently stored columns
public columns ( array | null $cols = null ) : array | $this
$cols array | null arrays with columns to be inserted
return array | $this

query() public method

Sets the query object to be used as the values expression to be evaluated to insert records in the table. If no params are passed, then it returns the currently stored query
public query ( Query $query = null ) : Query | null
$query Cake\Database\Query The query to set/get
return Cake\Database\Query | null

sql() public method

Convert the values into a SQL string with placeholders.
public sql ( ValueBinder $generator ) : string
$generator Cake\Database\ValueBinder Placeholder generator object
return string

traverse() public method

This method will also traverse any queries that are to be used in the INSERT values.
public traverse ( callable $visitor ) : void
$visitor callable The visitor to traverse the expression with.
return void

values() public method

Sets the values to be inserted. If no params are passed, then it returns the currently stored values
public values ( array | null $values = null ) : array | $this
$values array | null arrays with values to be inserted
return array | $this

Property Details

$_castedExpressions protected_oe property

Whether or not values have been casted to expressions already.
protected string $_castedExpressions
return string

$_columns protected_oe property

List of columns to ensure are part of the insert.
protected array $_columns
return array

$_query protected_oe property

The Query object to use as a values expression
protected Query,Cake\Database|null $_query
return Cake\Database\Query | null

$_values protected_oe property

Array of values to insert.
protected array $_values
return array