CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.6 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.6
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 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

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
      • Dialect
      • Driver
      • Exception
      • Expression
      • Log
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

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.

Namespace: Cake\Database\Expression

Property Summary

  • $_castedExpressions protected
    bool

    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

  • $_typeMap protected
    Cake\Database\TypeMap
  • $_values protected
    array

    Array of values to insert.

Method Summary

  • __construct() public

    Constructor

  • _castToExpression() protected

    Conditionally converts the passed value to an ExpressionInterface object if the type class implements the ExpressionTypeInterface. Otherwise, returns the value unmodified.

  • _columnNames() protected

    Get the bare column names.

  • _processExpressions() protected

    Converts values that need to be casted to expressions

  • _requiresToExpressionCasting() protected

    Returns an array with the types that require values to be casted to expressions, out of the list of type names passed as parameter.

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

  • defaultTypes() public deprecated

    Allows setting default types when chaining query

  • getColumns() public

    Gets the columns to be inserted.

  • getDefaultTypes() public

    Gets default types of current type map.

  • getQuery() public

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

  • getTypeMap() public

    Returns the existing type map.

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

  • setDefaultTypes() public

    Allows setting default types when chaining query.

  • setQuery() public

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

  • setTypeMap() public

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

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

  • typeMap() public deprecated

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

  • 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

_castToExpression() ¶ protected

_castToExpression(mixed $value, string $type): mixed

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

_columnNames() ¶ protected

_columnNames(): array

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

Converts values that need to be casted to expressions

Returns
void

_requiresToExpressionCasting() ¶ protected

_requiresToExpressionCasting(array $types): array

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

add() ¶ public

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

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

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

columns() ¶ public

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.

Parameters
array|null $cols optional

Array with columns to be inserted.

Returns
array|$this

defaultTypes() ¶ public

defaultTypes(array|null $types = null): $this|array

Allows setting default types when chaining query

Parameters
array|null $types optional

The array of types to set.

Returns
$this|array

getColumns() ¶ public

getColumns(): array

Gets the columns to be inserted.

Returns
array

getDefaultTypes() ¶ public

getDefaultTypes(): array

Gets default types of current type map.

Returns
array

getQuery() ¶ public

getQuery(): Cake\Database\Query|null

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

getTypeMap() ¶ public

getTypeMap(): Cake\Database\TypeMap

Returns the existing type map.

Returns
Cake\Database\TypeMap

getValues() ¶ public

getValues(): array

Gets the values to be inserted.

Returns
array

query() ¶ public

query(Cake\Database\Query|null $query = null): Cake\Database\Query|null|$this

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

Parameters
Cake\Database\Query|null $query optional

The query to set

Returns
Cake\Database\Query|null|$this

setColumns() ¶ public

setColumns(array $cols): $this

Sets the columns to be inserted.

Parameters
array $cols

Array with columns to be inserted.

Returns
$this

setDefaultTypes() ¶ public

setDefaultTypes(array $types): $this

Allows setting default types when chaining query.

Parameters
array $types

The array of types to set.

Returns
$this

setQuery() ¶ public

setQuery(Cake\Database\Query $query): $this

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

setTypeMap() ¶ public

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

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

setValues() ¶ public

setValues(array $values): $this

Sets the values to be inserted.

Parameters
array $values

Array with values to be inserted.

Returns
$this

sql() ¶ public

sql(Cake\Database\ValueBinder $generator): string

Convert the values into a SQL string with placeholders.

Parameters
Cake\Database\ValueBinder $generator

Placeholder generator object

Returns
string

traverse() ¶ public

traverse(callable $visitor): void

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.

Returns
void

typeMap() ¶ public

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

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

Parameters
array|Cake\Database\TypeMap|null $typeMap optional

Creates a TypeMap if array, otherwise sets the given TypeMap

Returns
$this|Cake\Database\TypeMap

values() ¶ public

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

Parameters
array|null $values optional

Array with values to be inserted.

Returns
array|$this

Property Detail

$_castedExpressions ¶ protected

Whether or not values have been casted to expressions already.

Type
bool

$_columns ¶ protected

List of columns to ensure are part of the insert.

Type
array

$_query ¶ protected

The Query object to use as a values expression

Type
Cake\Database\Query|null

$_typeMap ¶ protected

Type
Cake\Database\TypeMap

$_values ¶ protected

Array of values to insert.

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs