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

  • Connection
  • Driver
  • FieldTypeConverter
  • FunctionsBuilder
  • Query
  • SchemaCache
  • Type
  • TypeMap

Interfaces

  • DriverInterface
  • ExpressionInterface
  • StatementInterface
  • TypedResultInterface
  • TypeInterface

Traits

  • SqlDialectTrait
  • TypeConverterTrait
  • TypedResultTrait
  • TypeMapTrait

Exceptions

  • Exception

Class FunctionsBuilder

Contains methods related to generating FunctionExpression objects with most commonly used SQL functions. This acts as a factory for FunctionExpression objects.

Namespace: Cake\Database
Location: Database/FunctionsBuilder.php

Method Summary

  • __call() public
    Magic method dispatcher to create custom SQL function calls
  • _build() protected

    Returns a new instance of a FunctionExpression. This is used for generating arbitrary function calls in the final SQL string.

  • _literalArgumentFunction() protected

    Helper function to build a function expression that only takes one literal argument.

  • avg() public
    Returns a FunctionExpression representing a call to SQL AVG function.
  • coalesce() public
    Returns a FunctionExpression representing a call to SQL COALESCE function.
  • concat() public
    Returns a FunctionExpression representing a string concatenation
  • count() public
    Returns a FunctionExpression representing a call to SQL COUNT function.
  • dateAdd() public
    Add the time unit to the date expression
  • dateDiff() public

    Returns a FunctionExpression representing the difference in days between two dates.

  • datePart() public
    Returns the specified date part from the SQL expression.
  • dayOfWeek() public

    Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...

  • extract() public
    Returns the specified date part from the SQL expression.
  • max() public
    Returns a FunctionExpression representing a call to SQL MAX function.
  • min() public
    Returns a FunctionExpression representing a call to SQL MIN function.
  • now() public

    Returns a FunctionExpression representing a call that will return the current date and time. By default it returns both date and time, but you can also make it generate only the date or only the time.

  • rand() public
    Returns a FunctionExpression representing a call to SQL RAND function.
  • sum() public
    Returns a FunctionExpression representing a call to SQL SUM function.
  • weekday() public

    Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...

Method Detail

__call() public ¶

__call( string $name , array $args )

Magic method dispatcher to create custom SQL function calls

Parameters
string $name
the SQL function name to construct
array $args

list with up to 3 arguments, first one being an array with parameters for the SQL function, the second one a list of types to bind to those params, and the third one the return type of the function

Returns
Cake\Database\Expression\FunctionExpression

_build() protected ¶

_build( string $name , array $params = [] , array $types = [] , string $return = 'string' )

Returns a new instance of a FunctionExpression. This is used for generating arbitrary function calls in the final SQL string.

Parameters
string $name
the name of the SQL function to constructed
array $params optional []
list of params to be passed to the function
array $types optional []
list of types for each function param
string $return optional 'string'
The return type of the function expression
Returns
Cake\Database\Expression\FunctionExpression

_literalArgumentFunction() protected ¶

_literalArgumentFunction( string $name , mixed $expression , array $types = [] , string $return = 'string' )

Helper function to build a function expression that only takes one literal argument.

Parameters
string $name
name of the function to build
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
string $return optional 'string'
The return type for the function
Returns
Cake\Database\Expression\FunctionExpression

avg() public ¶

avg( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL AVG function.

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

coalesce() public ¶

coalesce( array $args , array $types = [] )

Returns a FunctionExpression representing a call to SQL COALESCE function.

Parameters
array $args
List of expressions to evaluate as function parameters
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

concat() public ¶

concat( array $args , array $types = [] )

Returns a FunctionExpression representing a string concatenation

Parameters
array $args
List of strings or expressions to concatenate
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

count() public ¶

count( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL COUNT function.

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

dateAdd() public ¶

dateAdd( string $expression , string $value , string $unit , array $types = [] )

Add the time unit to the date expression

Parameters
string $expression
Expression to obtain the date part from.
string $value
Value to be added. Use negative to subtract.
string $unit
Unit of the value e.g. hour or day.
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

dateDiff() public ¶

dateDiff( array $args , array $types = [] )

Returns a FunctionExpression representing the difference in days between two dates.

Parameters
array $args
List of expressions to obtain the difference in days.
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

datePart() public ¶

datePart( string $part , string $expression , array $types = [] )

Returns the specified date part from the SQL expression.

Parameters
string $part
Part of the date to return.
string $expression
Expression to obtain the date part from.
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

dayOfWeek() public ¶

dayOfWeek( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

extract() public ¶

extract( string $part , string $expression , array $types = [] )

Returns the specified date part from the SQL expression.

Parameters
string $part
Part of the date to return.
string $expression
Expression to obtain the date part from.
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

max() public ¶

max( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL MAX function.

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

min() public ¶

min( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL MIN function.

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

now() public ¶

now( string $type = 'datetime' )

Returns a FunctionExpression representing a call that will return the current date and time. By default it returns both date and time, but you can also make it generate only the date or only the time.

Parameters
string $type optional 'datetime'
(datetime|date|time)
Returns
Cake\Database\Expression\FunctionExpression

rand() public ¶

rand( )

Returns a FunctionExpression representing a call to SQL RAND function.

Returns
Cake\Database\Expression\FunctionExpression

sum() public ¶

sum( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL SUM function.

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression

weekday() public ¶

weekday( mixed $expression , array $types = [] )

Returns a FunctionExpression representing a call to SQL WEEKDAY function. 1 - Sunday, 2 - Monday, 3 - Tuesday...

Parameters
mixed $expression
the function argument
array $types optional []
list of types to bind to the arguments
Returns
Cake\Database\Expression\FunctionExpression
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