CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.8 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.8
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Command
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
      • Retry
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Exception
      • Middleware
      • Session
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • BetweenExpression
  • CaseExpression
  • Comparison
  • FunctionExpression
  • IdentifierExpression
  • OrderByExpression
  • OrderClauseExpression
  • QueryExpression
  • TupleComparison
  • UnaryExpression
  • ValuesExpression

Interfaces

  • FieldInterface

Traits

  • FieldTrait

Class ValuesExpression

An expression object to contain values being inserted.

Helps generate SQL with the correct number of placeholders and bind values correctly into the statement.

Cake\Database\Expression\ValuesExpression implements Cake\Database\ExpressionInterface uses Cake\Database\Type\ExpressionTypeCasterTrait , Cake\Database\TypeMapTrait
Namespace: Cake\Database\Expression
Location: Database/Expression/ValuesExpression.php

Properties summary

  • $_castedExpressions protected
    boolean

    Whether or not values have been casted to expressions already.

  • $_columns protected
    array
    List of columns to ensure are part of the insert.
  • $_query protected
    Cake\Database\Query|null
    The Query object to use as a values expression
  • $_values protected
    array
    Array of values to insert.

Inherited Properties

  • _typeMap

Method Summary

  • __construct() public
    Constructor
  • _columnNames() protected
    Get the bare column names.
  • _processExpressions() protected
    Converts values that need to be casted to expressions
  • add() public
    Add a row of data to be inserted.
  • columns() public deprecated

    Sets the columns to be inserted. If no params are passed, then it returns the currently stored columns.

  • getColumns() public
    Gets the columns to be inserted.
  • getQuery() public

    Gets the query object to be used as the values expression to be evaluated to insert records in the table.

  • getValues() public
    Gets the values to be inserted.
  • query() public deprecated

    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

  • setColumns() public
    Sets the columns to be inserted.
  • setQuery() public

    Sets the query object to be used as the values expression to be evaluated to insert records in the table.

  • setValues() public
    Sets the values to be inserted.
  • sql() public
    Convert the values into a SQL string with placeholders.
  • traverse() public
    Traverse the values expression.
  • values() public deprecated

    Sets the values to be inserted. If no params are passed, then it returns the currently stored values

Method Detail

__construct() public ¶

__construct( array $columns , Cake\Database\TypeMap $typeMap )

Constructor

Parameters
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

_columnNames() protected ¶

_columnNames( )

Get the bare column names.

Because column names could be identifier quoted, we need to strip the identifiers off of the columns.

Returns
array

_processExpressions() protected ¶

_processExpressions( )

Converts values that need to be casted to expressions

add() public ¶

add( array|Cake\Database\Query $data )

Add a row of data to be inserted.

Parameters
array|Cake\Database\Query $data

Array of data to append into the insert, or a query for doing INSERT INTO .. SELECT style commands

Throws
Cake\Database\Exception
When mixing array + Query data types.

columns() public deprecated ¶

columns( array|null $cols = null )

Sets the columns to be inserted. If no params are passed, then it returns the currently stored columns.

Deprecated
3.4.0 Use setColumns()/getColumns() instead.
Parameters
array|null $cols optional null
Array with columns to be inserted.
Returns
array|Cake\Database\Expression\ValuesExpression
$this

getColumns() public ¶

getColumns( )

Gets the columns to be inserted.

Returns
array

getQuery() public ¶

getQuery( )

Gets the query object to be used as the values expression to be evaluated to insert records in the table.

Returns
Cake\Database\Query|null

getValues() public ¶

getValues( )

Gets the values to be inserted.

Returns
array

query() public deprecated ¶

query( Cake\Database\Query $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

Deprecated
3.4.0 Use setQuery()/getQuery() instead.
Parameters
Cake\Database\Query $query optional null
The query to set
Returns
Cake\Database\Query|null|Cake\Database\Expression\ValuesExpression
$this

setColumns() public ¶

setColumns( array $cols )

Sets the columns to be inserted.

Parameters
array $cols
Array with columns to be inserted.
Returns

$this

setQuery() public ¶

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.

Parameters
Cake\Database\Query $query
The query to set
Returns

$this

setValues() public ¶

setValues( array $values )

Sets the values to be inserted.

Parameters
array $values
Array with values to be inserted.
Returns

$this

sql() public ¶

sql( Cake\Database\ValueBinder $generator )

Convert the values into a SQL string with placeholders.

Parameters
Cake\Database\ValueBinder $generator
Placeholder generator object
Returns
string
Implementation of
Cake\Database\ExpressionInterface::sql()

traverse() public ¶

traverse( callable $visitor )

Traverse the values expression.

This method will also traverse any queries that are to be used in the INSERT values.

Parameters
callable $visitor
The visitor to traverse the expression with.
Implementation of
Cake\Database\ExpressionInterface::traverse()

values() public deprecated ¶

values( array|null $values = null )

Sets the values to be inserted. If no params are passed, then it returns the currently stored values

Deprecated
3.4.0 Use setValues()/getValues() instead.
Parameters
array|null $values optional null
Array with values to be inserted.
Returns
array|Cake\Database\Expression\ValuesExpression
$this

Methods used from Cake\Database\Type\ExpressionTypeCasterTrait

_castToExpression() protected ¶

_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.

Parameters
mixed $value
The value to converto to ExpressionInterface
string $type
The type name
Returns
mixed

_requiresToExpressionCasting() protected ¶

_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.

Parameters
array $types
List of type names
Returns
array

Methods used from Cake\Database\TypeMapTrait

defaultTypes() public deprecated ¶

defaultTypes( array $types = null )

Allows setting default types when chaining query

Deprecated
3.4.0 Use setDefaultTypes()/getDefaultTypes() instead.
Parameters
array $types optional null
The array of types to set.
Returns

$this|array

getDefaultTypes() public ¶

getDefaultTypes( )

Gets default types of current type map.

Returns
array

getTypeMap() public ¶

getTypeMap( )

Returns the existing type map.

Returns
Cake\Database\TypeMap

setDefaultTypes() public ¶

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()

Parameters
array $types
The array of types to set.
Returns

$this
See
\Cake\Database\TypeMap::setDefaults()

setTypeMap() public ¶

setTypeMap( array|Cake\Database\TypeMap $typeMap )

Creates a new TypeMap if $typeMap is an array, otherwise exchanges it for the given one.

Parameters
array|Cake\Database\TypeMap $typeMap
Creates a TypeMap if array, otherwise sets the given TypeMap
Returns

$this

typeMap() public deprecated ¶

typeMap( array|Cake\Database\TypeMap|null $typeMap = null )

Creates a new TypeMap if $typeMap is an array, otherwise returns the existing type map or exchanges it for the given one.

Deprecated
3.4.0 Use setTypeMap()/getTypeMap() instead.
Parameters
array|Cake\Database\TypeMap|null $typeMap optional null
Creates a TypeMap if array, otherwise sets the given TypeMap
Returns

$this|\Cake\Database\TypeMap

Properties detail

$_castedExpressions ¶

protected boolean

Whether or not values have been casted to expressions already.

false

$_columns ¶

protected array

List of columns to ensure are part of the insert.

[]

$_query ¶

protected Cake\Database\Query|null

The Query object to use as a values expression

$_values ¶

protected array

Array of values to insert.

[]
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs