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 Comparison

A Comparison is a type of query expression that represents an operation involving a field an operator and a value. In its most common form the string representation of a comparison is field = value

Cake\Database\Expression\Comparison implements Cake\Database\ExpressionInterface, Cake\Database\Expression\FieldInterface uses Cake\Database\Type\ExpressionTypeCasterTrait , Cake\Database\Expression\FieldTrait
Direct Subclasses
  • Cake\Database\Expression\TupleComparison
Namespace: Cake\Database\Expression
Location: Database/Expression/Comparison.php

Properties summary

  • $_isMultiple protected
    boolean
    Whether or not the value in this expression is a traversable
  • $_operator protected
    string
    The operator used for comparing field and value
  • $_type protected
    string|array
    The type to be used for casting the value to a database representation
  • $_value protected
    mixed
    The value to be used in the right hand side of the operation
  • $_valueExpressions protected
    Cake\Database\ExpressionInterface[]

    A cached list of ExpressionInterface objects that were found in the value for this expression.

Inherited Properties

  • _field

Method Summary

  • __clone() public
    Create a deep clone.
  • __construct() public
    Constructor
  • _bindValue() protected
    Registers a value in the placeholder generator and returns the generated placeholder
  • _collectExpressions() protected

    Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.

  • _flattenValue() protected

    Converts a traversable value into a set of placeholders generated by $generator and separated by ,

  • _stringExpression() protected

    Returns a template and a placeholder for the value after registering it with the placeholder $generator

  • getOperator() public
    Returns the operator used for comparison
  • getValue() public
    Returns the value used for comparison
  • setOperator() public
    Sets the operator to use for the comparison
  • setValue() public
    Sets the value
  • sql() public
    Convert the expression into a SQL fragment.
  • traverse() public

    Iterates over each part of the expression recursively for every level of the expressions tree and executes the $visitor callable passing as first parameter the instance of the expression currently being iterated.

Method Detail

__clone() public ¶

__clone( )

Create a deep clone.

Clones the field and value if they are expression objects.

__construct() public ¶

__construct( string|Cake\Database\ExpressionInterface $field , mixed $value , string $type , string $operator )

Constructor

Parameters
string|Cake\Database\ExpressionInterface $field
the field name to compare to a value
mixed $value
The value to be used in comparison
string $type
the type name used to cast the value
string $operator
the operator used for comparing field and value

_bindValue() protected ¶

_bindValue( mixed $value , Cake\Database\ValueBinder $generator , string $type )

Registers a value in the placeholder generator and returns the generated placeholder

Parameters
mixed $value
The value to bind
Cake\Database\ValueBinder $generator
The value binder to use
string $type
The type of $value
Returns
string
generated placeholder

_collectExpressions() protected ¶

_collectExpressions( array|Traversable $values )

Returns an array with the original $values in the first position and all ExpressionInterface objects that could be found in the second position.

Parameters
array|Traversable $values
The rows to insert
Returns
array

_flattenValue() protected ¶

_flattenValue( array|Traversable $value , Cake\Database\ValueBinder $generator , string|array|null $type = 'string' )

Converts a traversable value into a set of placeholders generated by $generator and separated by ,

Parameters
array|Traversable $value
the value to flatten
Cake\Database\ValueBinder $generator
The value binder to use
string|array|null $type optional 'string'
the type to cast values to
Returns
string

_stringExpression() protected ¶

_stringExpression( Cake\Database\ValueBinder $generator )

Returns a template and a placeholder for the value after registering it with the placeholder $generator

Parameters
Cake\Database\ValueBinder $generator
The value binder to use.
Returns
array
First position containing the template and the second a placeholder

getOperator() public ¶

getOperator( )

Returns the operator used for comparison

Returns
string

getValue() public ¶

getValue( )

Returns the value used for comparison

Returns
mixed

setOperator() public ¶

setOperator( string $operator )

Sets the operator to use for the comparison

Parameters
string $operator
The operator to be used for the comparison.

setValue() public ¶

setValue( mixed $value )

Sets the value

Parameters
mixed $value
The value to compare

sql() public ¶

sql( Cake\Database\ValueBinder $generator )

Convert the expression into a SQL fragment.

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

traverse() public ¶

traverse( callable $callable )

Iterates over each part of the expression recursively for every level of the expressions tree and executes the $visitor callable passing as first parameter the instance of the expression currently being iterated.

Parameters
callable $callable
$visitor The callable to apply to all nodes.
Implementation of
Cake\Database\ExpressionInterface::traverse()

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\Expression\FieldTrait

getField() public ¶

getField( )

Returns the field name

Returns
string|Cake\Database\ExpressionInterface

setField() public ¶

setField( string|Cake\Database\ExpressionInterface $field )

Sets the field name

Parameters
string|Cake\Database\ExpressionInterface $field
The field to compare with.

Properties detail

$_isMultiple ¶

protected boolean

Whether or not the value in this expression is a traversable

false

$_operator ¶

protected string

The operator used for comparing field and value

$_type ¶

protected string|array

The type to be used for casting the value to a database representation

$_value ¶

protected mixed

The value to be used in the right hand side of the operation

$_valueExpressions ¶

protected Cake\Database\ExpressionInterface[]

A cached list of ExpressionInterface objects that were found in the value for this expression.

[]
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