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

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.7
      • 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
  1: <?php
  2: /**
  3:  * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4:  * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5:  *
  6:  * Licensed under The MIT License
  7:  * For full copyright and license information, please see the LICENSE.txt
  8:  * Redistributions of files must retain the above copyright notice.
  9:  *
 10:  * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
 11:  * @link          https://cakephp.org CakePHP(tm) Project
 12:  * @since         3.0.0
 13:  * @license       https://opensource.org/licenses/mit-license.php MIT License
 14:  */
 15: namespace Cake\Database\Expression;
 16: 
 17: use Cake\Database\ExpressionInterface;
 18: use Cake\Database\ValueBinder;
 19: 
 20: /**
 21:  * An expression object that represents an expression with only a single operand.
 22:  */
 23: class UnaryExpression implements ExpressionInterface
 24: {
 25: 
 26:     /**
 27:      * Indicates that the operation is in pre-order
 28:      *
 29:      */
 30:     const PREFIX = 0;
 31: 
 32:     /**
 33:      * Indicates that the operation is in post-order
 34:      *
 35:      */
 36:     const POSTFIX = 1;
 37: 
 38:     /**
 39:      * The operator this unary expression represents
 40:      *
 41:      * @var string
 42:      */
 43:     protected $_operator;
 44: 
 45:     /**
 46:      * Holds the value which the unary expression operates
 47:      *
 48:      * @var mixed
 49:      */
 50:     protected $_value;
 51: 
 52:     /**
 53:      * Where to place the operator
 54:      *
 55:      * @var int
 56:      */
 57:     protected $_mode;
 58: 
 59:     /**
 60:      * Constructor
 61:      *
 62:      * @param string $operator The operator to used for the expression
 63:      * @param mixed $value the value to use as the operand for the expression
 64:      * @param int $mode either UnaryExpression::PREFIX or UnaryExpression::POSTFIX
 65:      */
 66:     public function __construct($operator, $value, $mode = self::PREFIX)
 67:     {
 68:         $this->_operator = $operator;
 69:         $this->_value = $value;
 70:         $this->_mode = $mode;
 71:     }
 72: 
 73:     /**
 74:      * Converts the expression to its string representation
 75:      *
 76:      * @param \Cake\Database\ValueBinder $generator Placeholder generator object
 77:      * @return string
 78:      */
 79:     public function sql(ValueBinder $generator)
 80:     {
 81:         $operand = $this->_value;
 82:         if ($operand instanceof ExpressionInterface) {
 83:             $operand = $operand->sql($generator);
 84:         }
 85: 
 86:         if ($this->_mode === self::POSTFIX) {
 87:             return '(' . $operand . ') ' . $this->_operator;
 88:         }
 89: 
 90:         return $this->_operator . ' (' . $operand . ')';
 91:     }
 92: 
 93:     /**
 94:      * {@inheritDoc}
 95:      *
 96:      */
 97:     public function traverse(callable $callable)
 98:     {
 99:         if ($this->_value instanceof ExpressionInterface) {
100:             $callable($this->_value);
101:             $this->_value->traverse($callable);
102:         }
103:     }
104: 
105:     /**
106:      * Perform a deep clone of the inner expression.
107:      *
108:      * @return void
109:      */
110:     public function __clone()
111:     {
112:         if ($this->_value instanceof ExpressionInterface) {
113:             $this->_value = clone $this->_value;
114:         }
115:     }
116: }
117: 
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