CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 周边商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 加入我们
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • LinkedIn
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 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

命名空间

  • 全局
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Query
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

类 FunctionsBuilder

包含与使用最常见的 SQL 函数生成 FunctionExpression 对象相关的方法。它充当 FunctionExpression 对象的工厂。

命名空间: Cake\Database

方法摘要

  • __call() public

    创建自定义 SQL 函数调用的魔术方法调度器

  • aggregate() public

    帮助方法,用于创建任意 SQL 聚合函数调用。

  • avg() public

    返回表示对 SQL AVG 函数的调用的 AggregateExpression。

  • cast() public

    返回表示 SQL CAST 的 FunctionExpression。

  • coalesce() public

    返回表示对 SQL COALESCE 函数的调用的 FunctionExpression。

  • concat() public

    返回表示字符串连接的 FunctionExpression

  • count() public

    返回表示对 SQL COUNT 函数的调用的 AggregateExpression。

  • dateAdd() public

    将时间单位添加到日期表达式

  • dateDiff() public

    返回表示两个日期之间天数差别的 FunctionExpression。

  • datePart() public

    返回 SQL 表达式中指定的日期部分。

  • dayOfWeek() public

    返回表示对 SQL WEEKDAY 函数的调用的 FunctionExpression。1 - 星期日,2 - 星期一,3 - 星期二...

  • extract() public

    返回 SQL 表达式中指定的日期部分。

  • jsonValue() public

    返回表示 Json 值的 FunctionExpression

  • lag() public

    返回表示对 SQL LAG() 的调用的 AggregateExpression。

  • lead() public

    返回表示对 SQL LEAD() 的调用的 AggregateExpression。

  • max() public

    返回表示对 SQL MAX 函数的调用的 AggregateExpression。

  • min() public

    返回表示对 SQL MIN 函数的调用的 AggregateExpression。

  • now() public

    返回表示将返回当前日期和时间的调用的 FunctionExpression。默认情况下,它返回日期和时间,但您也可以使其仅生成日期或仅生成时间。

  • rand() public

    返回表示对 SQL RAND 函数的调用的 FunctionExpression。

  • rowNumber() public

    返回表示对 SQL ROW_NUMBER() 的调用的 AggregateExpression。

  • sum() public

    返回表示对 SQL SUM 函数的调用的 AggregateExpression。

  • toLiteralParam() protected

    从表达式或字符串文字创建函数参数数组。

  • weekday() public

    返回表示对 SQL WEEKDAY 函数的调用的 FunctionExpression。1 - 星期日,2 - 星期一,3 - 星期二...

方法详细信息

__call() ¶ public

__call(string $name, array $args): Cake\Database\Expression\FunctionExpression

创建自定义 SQL 函数调用的魔术方法调度器

参数
string $name

要构造的 SQL 函数名称

array $args

最多包含 3 个参数的列表,第一个是包含 SQL 函数参数的数组,第二个是绑定到这些参数的类型列表,第三个是函数的返回类型

返回
Cake\Database\Expression\FunctionExpression

aggregate() ¶ public

aggregate(string $name, array $params = [], array $types = [], string $return = 'float'): Cake\Database\Expression\AggregateExpression

帮助方法,用于创建任意 SQL 聚合函数调用。

参数
string $name

SQL 聚合函数名称

array $params optional

要传递给函数的参数数组。可以是包含文字值或标识符的关联数组:['value' => 'literal'] 或 `['value' => 'identifier']

array $types optional

与 $params 中使用的名称匹配的类型数组:['name' => 'type']

string $return optional

整个表达式的返回类型。默认为 float。

返回
Cake\Database\Expression\AggregateExpression

avg() ¶ public

avg(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression

返回表示对 SQL AVG 函数的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\AggregateExpression

cast() ¶ public

cast(Cake\Database\ExpressionInterface|string $field, string $dataType): Cake\Database\Expression\FunctionExpression

返回表示 SQL CAST 的 FunctionExpression。

$type 参数是 SQL 类型。返回表达式的返回类型是默认类型名称。使用 setReturnType() 更新它。

参数
Cake\Database\ExpressionInterface|string $field

要转换的字段或表达式。

string $dataType

SQL 数据类型

返回
Cake\Database\Expression\FunctionExpression

coalesce() ¶ public

coalesce(array $args, array $types = []): Cake\Database\Expression\FunctionExpression

返回表示对 SQL COALESCE 函数的调用的 FunctionExpression。

参数
array $args

要作为函数参数计算的表达式列表

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

concat() ¶ public

concat(array $args, array $types = []): Cake\Database\Expression\FunctionExpression

返回表示字符串连接的 FunctionExpression

参数
array $args

要连接的字符串或表达式列表

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

count() ¶ public

count(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression

返回表示对 SQL COUNT 函数的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\AggregateExpression

dateAdd() ¶ public

dateAdd(Cake\Database\ExpressionInterface|string $expression, string|int $value, string $unit, array $types = []): Cake\Database\Expression\FunctionExpression

将时间单位添加到日期表达式

参数
Cake\Database\ExpressionInterface|string $expression

表达式,用于获取日期部分。

string|int $value

要添加的值。使用负数来减去。

string $unit

值的单位,例如小时或天。

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

dateDiff() ¶ public

dateDiff(array $args, array $types = []): Cake\Database\Expression\FunctionExpression

返回表示两个日期之间天数差别的 FunctionExpression。

参数
array $args

表达式列表,用于获取天数差。

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

datePart() ¶ public

datePart(string $part, Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression

返回 SQL 表达式中指定的日期部分。

参数
string $part

要返回的日期部分。

Cake\Database\ExpressionInterface|string $expression

表达式,用于获取日期部分。

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

dayOfWeek() ¶ public

dayOfWeek(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression

返回表示对 SQL WEEKDAY 函数的调用的 FunctionExpression。1 - 星期日,2 - 星期一,3 - 星期二...

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

extract() ¶ public

extract(string $part, Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression

返回 SQL 表达式中指定的日期部分。

参数
string $part

要返回的日期部分。

Cake\Database\ExpressionInterface|string $expression

表达式,用于获取日期部分。

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

jsonValue() ¶ public

jsonValue(Cake\Database\ExpressionInterface|string $expression, string $jsonPath, array $types = []): Cake\Database\Expression\FunctionExpression

返回表示 Json 值的 FunctionExpression

参数
Cake\Database\ExpressionInterface|string $expression

Json 值或 json 字段

string $jsonPath

有效的 JSON PATH 查询

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression

lag() ¶ public

lag(Cake\Database\ExpressionInterface|string $expression, int $offset, mixed $default = null, string|null $type = null): Cake\Database\Expression\AggregateExpression

返回表示对 SQL LAG() 的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

在偏移量处计算的值

int $offset

行偏移量

mixed $default optional

如果偏移量不存在,则为默认值

string|null $type optional

lag 表达式的输出类型。默认为 float。

返回
Cake\Database\Expression\AggregateExpression

lead() ¶ public

lead(Cake\Database\ExpressionInterface|string $expression, int $offset, mixed $default = null, string|null $type = null): Cake\Database\Expression\AggregateExpression

返回表示对 SQL LEAD() 的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

在偏移量处计算的值

int $offset

行偏移量

mixed $default optional

如果偏移量不存在,则为默认值

string|null $type optional

lead 表达式的输出类型。默认为 float。

返回
Cake\Database\Expression\AggregateExpression

max() ¶ public

max(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression

返回表示对 SQL MAX 函数的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\AggregateExpression

min() ¶ public

min(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression

返回表示对 SQL MIN 函数的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\AggregateExpression

now() ¶ public

now(string $type = 'datetime'): Cake\Database\Expression\FunctionExpression

返回表示将返回当前日期和时间的调用的 FunctionExpression。默认情况下,它返回日期和时间,但您也可以使其仅生成日期或仅生成时间。

参数
string $type 可选

(datetime|date|time)

返回
Cake\Database\Expression\FunctionExpression

rand() ¶ public

rand(): Cake\Database\Expression\FunctionExpression

返回表示对 SQL RAND 函数的调用的 FunctionExpression。

返回
Cake\Database\Expression\FunctionExpression

rowNumber() ¶ public

rowNumber(): Cake\Database\Expression\AggregateExpression

返回表示对 SQL ROW_NUMBER() 的调用的 AggregateExpression。

返回
Cake\Database\Expression\AggregateExpression

sum() ¶ public

sum(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\AggregateExpression

返回表示对 SQL SUM 函数的调用的 AggregateExpression。

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\AggregateExpression

toLiteralParam() ¶ protected

toLiteralParam(Cake\Database\ExpressionInterface|string $expression): arrayCake\Database\ExpressionInterface|string>

从表达式或字符串文字创建函数参数数组。

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

返回
arrayCake\Database\ExpressionInterface|string>

weekday() ¶ public

weekday(Cake\Database\ExpressionInterface|string $expression, array $types = []): Cake\Database\Expression\FunctionExpression

返回表示对 SQL WEEKDAY 函数的调用的 FunctionExpression。1 - 星期日,2 - 星期一,3 - 星期二...

参数
Cake\Database\ExpressionInterface|string $expression

函数参数

array $types optional

要绑定到参数的类型列表

返回
Cake\Database\Expression\FunctionExpression
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 加入我们
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • LinkedIn
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成