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.0 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.0
      • 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
    • Console
    • Controller
    • Core
    • Database
      • Dialect
      • Driver
      • Exception
      • Expression
      • Log
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

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

Namespace: Cake\Database\Expression

Property Summary

  • $_field protected
    string

    The field name or expression to be used in the left hand side of the operator

  • $_operator protected
    string

    The operator used for comparing field and value

  • $_type protected
    string

    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

Method Summary

  • __construct() public

    Constructor

  • _bindValue() protected

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

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

  • getField() public

    Returns the field name

  • getOperator() public

    Returns the operator used for comparison

  • getValue() public

    Returns the value used for comparison

  • setField() public

    Sets the field name

  • 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

__construct() ¶ public

__construct(string $field, mixed $value, string $type, string $operator)

Constructor

Parameters
string $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): string

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

_flattenValue() ¶ protected

_flattenValue(array|Traversable $value, Cake\Database\ValueBinder $generator, string|array $type = null): 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 $type optional

the type to cast values to

Returns
string

_stringExpression() ¶ protected

_stringExpression(Cake\Database\ValueBinder $generator): array

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

getField() ¶ public

getField(): string|Cake\Database\ExpressionInterface

Returns the field name

Returns
string|Cake\Database\ExpressionInterface

getOperator() ¶ public

getOperator(): string

Returns the operator used for comparison

Returns
string

getValue() ¶ public

getValue(): mixed

Returns the value used for comparison

Returns
mixed

setField() ¶ public

setField(string $field): void

Sets the field name

Parameters
string $field

The field to compare with.

Returns
void

setOperator() ¶ public

setOperator(string $operator): void

Sets the operator to use for the comparison

Parameters
string $operator

The operator to be used for the comparison.

Returns
void

setValue() ¶ public

setValue(mixed $value): void

Sets the value

Parameters
mixed $value

The value to compare

Returns
void

sql() ¶ public

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

Convert the expression into a SQL fragment.

Parameters
Cake\Database\ValueBinder $generator

Placeholder generator object

Returns
string

traverse() ¶ public

traverse(callable $callable): void

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
Returns
void

Property Detail

$_field ¶ protected

The field name or expression to be used in the left hand side of the operator

Type
string

$_operator ¶ protected

The operator used for comparing field and value

Type
string

$_type ¶ protected

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

Type
string

$_value ¶ protected

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

Type
mixed
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