CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • 烘焙坊
    • 特色资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 时事通讯
    • 领英
    • 优酷
    • 脸书
    • 推特
    • 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
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
    • 数据库
      • 驱动程序
      • 异常
      • 表达式
      • 日志
      • 查询
      • 重试
      • 模式
      • 语句
      • 类型
    • 数据源
    • 错误
    • 事件
    • 表单
    • HTTP
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 工具
    • 验证
    • 视图

类 ComparisonExpression

比较是一种查询表达式类型,它表示涉及字段、运算符和值的运算。在最常见的形式中,比较的字符串表示形式为field = value

命名空间: Cake\Database\Expression

属性摘要

  • $_field protected
    Cake\Database\ExpressionInterface|array|string

    要在运算符左侧使用的字段名称或表达式

  • $_isMultiple protected
    bool

    此表达式中的值是否为可遍历的

  • $_operator protected
    string

    用于比较字段和值的运算符

  • $_type protected
    string|null

    用于将值转换为数据库表示形式的类型

  • $_value protected
    mixed

    要在运算符右侧使用的值

  • $_valueExpressions protected
    arrayCake\Database\ExpressionInterface>

    此表达式值中找到的 ExpressionInterface 对象的缓存列表。

方法摘要

  • __clone() public

    创建深度克隆。

  • __construct() public

    构造函数

  • _bindValue() protected

    在占位符生成器中注册一个值,并返回生成的占位符

  • _castToExpression() protected

    如果类型类实现了 ExpressionTypeInterface,则有条件地将传入的值转换为 ExpressionInterface 对象。否则,返回未修改的值。

  • _collectExpressions() protected

    返回一个数组,其中第一个位置是原始 $values,第二个位置是可以在其中找到的所有 ExpressionInterface 对象。

  • _flattenValue() protected

    将可遍历的值转换为由 $binder 生成的占位符集,并用, 分隔

  • _requiresToExpressionCasting() protected

    返回一个数组,其中包含需要将值转换为表达式类型的类型,这些类型来自作为参数传入的类型名称列表。

  • _stringExpression() protected

    在使用占位符 $binder 注册值后,返回一个模板和一个占位符。

  • getField() public

    返回字段名称

  • getOperator() public

    返回用于比较的运算符

  • getValue() public

    返回用于比较的值

  • setField() public

    设置字段名称

  • setOperator() public

    设置用于比较的运算符

  • setValue() public

    设置值

  • sql() public

    将节点转换为 SQL 字符串片段。

  • traverse() public

    递归地迭代表达式的每个部分,针对表达式的树的每个级别,并执行回调,将当前正在迭代的表达式的实例作为第一个参数传递。

方法详细信息

__clone() ¶ public

__clone(): void

创建深度克隆。

如果字段和值是表达式对象,则克隆它们。

返回
void

__construct() ¶ public

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

构造函数

参数
Cake\Database\ExpressionInterface|string $field

要与值比较的字段名称

mixed $value

要在比较中使用的值

string|null $type optional

用于转换值的类型名称

string $operator optional

用于比较字段和值的运算符

_bindValue() ¶ protected

_bindValue(mixed $value, Cake\Database\ValueBinder $binder, string|null $type = null): string

在占位符生成器中注册一个值,并返回生成的占位符

参数
mixed $value

要绑定的值

Cake\Database\ValueBinder $binder

要使用的值绑定器

string|null $type optional

$value 的类型

返回
string

_castToExpression() ¶ protected

_castToExpression(mixed $value, string|null $type = null): mixed

如果类型类实现了 ExpressionTypeInterface,则有条件地将传入的值转换为 ExpressionInterface 对象。否则,返回未修改的值。

参数
mixed $value

要转换为 ExpressionInterface 的值

string|null $type optional

类型名称

返回
mixed

_collectExpressions() ¶ protected

_collectExpressions(Cake\Database\ExpressionInterface|iterable $values): array

返回一个数组,其中第一个位置是原始 $values,第二个位置是可以在其中找到的所有 ExpressionInterface 对象。

参数
Cake\Database\ExpressionInterface|iterable $values

要插入的行

返回
array

_flattenValue() ¶ protected

_flattenValue(iterable $value, Cake\Database\ValueBinder $binder, string|null $type = null): string

将可遍历的值转换为由 $binder 生成的占位符集,并用, 分隔

参数
iterable $value

要展平的值

Cake\Database\ValueBinder $binder

要使用的值绑定器

string|null $type optional

要将值转换成的类型

返回
string

_requiresToExpressionCasting() ¶ protected

_requiresToExpressionCasting(array $types): array

返回一个数组,其中包含需要将值转换为表达式类型的类型,这些类型来自作为参数传入的类型名称列表。

参数
array $types

类型名称列表

返回
array

_stringExpression() ¶ protected

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

在使用占位符 $binder 注册值后,返回一个模板和一个占位符。

参数
Cake\Database\ValueBinder $binder

要使用的值绑定器。

返回
array

getField() ¶ public

getField(): Cake\Database\ExpressionInterface|array|string

返回字段名称

返回
Cake\Database\ExpressionInterface|array|string

getOperator() ¶ public

getOperator(): string

返回用于比较的运算符

返回
string

getValue() ¶ public

getValue(): mixed

返回用于比较的值

返回
mixed

setField() ¶ public

setField(Cake\Database\ExpressionInterface|array|string $field): void

设置字段名称

参数
Cake\Database\ExpressionInterface|array|string $field

要比较的字段。

返回
void

setOperator() ¶ public

setOperator(string $operator): void

设置用于比较的运算符

参数
string $operator

要用于比较的运算符。

返回
void

setValue() ¶ public

setValue(mixed $value): void

设置值

参数
mixed $value

要比较的值

返回
void

sql() ¶ public

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

将节点转换为 SQL 字符串片段。

参数
Cake\Database\ValueBinder $binder
返回
string

traverse() ¶ public

traverse(Closure $callback): $this

递归地迭代表达式的每个部分,针对表达式的树的每个级别,并执行回调,将当前正在迭代的表达式的实例作为第一个参数传递。

参数
Closure $callback
返回
$this

属性详细信息

$_field ¶ protected

要在运算符左侧使用的字段名称或表达式

类型
Cake\Database\ExpressionInterface|array|string

$_isMultiple ¶ 受保护

此表达式中的值是否为可遍历的

类型
bool

$_operator ¶ 受保护

用于比较字段和值的运算符

类型
string

$_type ¶ 受保护

用于将值转换为数据库表示形式的类型

类型
string|null

$_value ¶ 受保护

要在运算符右侧使用的值

类型
mixed

$_valueExpressions ¶ 受保护

此表达式值中找到的 ExpressionInterface 对象的缓存列表。

类型
arrayCake\Database\ExpressionInterface>
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • 烘焙坊
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 时事通讯
  • 领英
  • 优酷
  • 脸书
  • 推特
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成