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

类 SqliteSchemaDialect

Sqlite 的模式管理/反射功能

命名空间: Cake\Database\Schema

属性概述

  • $_driver protected
    Cake\Database\Driver

    正在使用的驱动程序实例。

  • $_hasSequences protected
    bool

    此 SQLite 连接中是否存在任何包含序列的表。

方法概述

  • __construct() public

    构造函数

  • _applyTypeSpecificColumnConversion() protected

    尝试使用匹配的数据库类型将 SQL 列定义转换为抽象类型定义。

  • _convertColumn() protected

    将列定义转换为抽象类型。

  • _convertConstraintColumns() protected

    将外键约束引用转换为有效的字符串化列表

  • _convertOnClause() protected

    将字符串 on 子句转换为抽象的 on 子句。

  • _defaultValue() protected

    操作默认值。

  • _foreignOnClause() protected

    为外键生成 ON 子句。

  • _getTypeSpecificColumnSql() protected

    尝试使用匹配的数据库类型为表中的单个列生成 SQL 片段。

  • addConstraintSql() public

    生成将外键约束添加到表的 SQL 查询

  • columnSql() public

    为表中的单个列生成 SQL 片段。

  • constraintSql() public

    生成用于定义表约束的 SQL 片段。

  • convertColumnDescription() public

    将字段描述结果转换为抽象模式字段。

  • convertForeignKeyDescription() public

    将外键描述转换为 Table 对象上的约束。

  • convertIndexDescription() public

    将索引描述结果转换为抽象模式索引或约束。

  • convertOptionsDescription() public

    将选项数据转换为表选项。

  • createTableSql() public

    生成创建表的 SQL 语句。

  • describeColumnSql() public

    生成描述表的 SQL 语句。

  • describeForeignKeySql() public

    生成描述表中外键的 SQL 语句。

  • describeIndexSql() public

    生成描述表中索引的 SQL 语句。

  • describeOptionsSql() public

    生成描述表选项的 SQL 语句

  • dropConstraintSql() public

    生成从表中删除外键约束所需的 SQL 查询

  • dropTableSql() public

    生成删除表的 SQL 语句。

  • hasSequences() public

    返回此 SQLite 连接中是否存在任何包含序列的表

  • indexSql() public

    为表中的单个索引生成 SQL 片段。

  • listTablesSql() public

    生成列出表和视图的 SQL 语句。

  • listTablesWithoutViewsSql() public

    生成列出表的 SQL 语句,不包括所有视图。

  • normalizePossiblyQuotedIdentifier() protected

    从标识符中删除可能的转义字符和周围的引号。

  • possiblyQuotedIdentifierRegex() protected

    生成一个正则表达式来匹配可能用任何支持的引号引起来或不引起来的标识符。

  • truncateTableSql() public

    生成截断表的 SQL 语句。

方法详情

__construct() ¶ public

__construct(Cake\Database\Driver $driver)

构造函数

此构造函数将连接驱动程序,以便当驱动程序未连接时,columnSql() 等方法将失败。

参数
Cake\Database\Driver $driver

要使用的驱动程序。

_applyTypeSpecificColumnConversion() ¶ protected

_applyTypeSpecificColumnConversion(string $columnType, array $definition): array|null

尝试使用匹配的数据库类型将 SQL 列定义转换为抽象类型定义。

参数
string $columnType

列类型。

array $definition

列定义。

返回值
array|null

_convertColumn() ¶ protected

_convertColumn(string $column): array<string, mixed>

将列定义转换为抽象类型。

返回的类型将是 Cake\Database\TypeFactory 可以处理的类型。

参数
string $column

列类型 + 长度

返回值
array<string, mixed>
抛出
Cake\Database\Exception\DatabaseException
当无法解析列类型时

_convertConstraintColumns() ¶ protected

_convertConstraintColumns(list<string>|string $references): string

将外键约束引用转换为有效的字符串化列表

参数
list<string>|string $references

外键约束语句引用的列

返回值
string

_convertOnClause() ¶ protected

_convertOnClause(string $clause): string

将字符串 on 子句转换为抽象的 on 子句。

参数
string $clause

要转换的 on 子句。

返回值
string

_defaultValue() ¶ protected

_defaultValue(string|int|null $default): string|int|null

操作默认值。

Sqlite 在默认值中包含引号和裸 NULL。我们需要删除它们。

参数
string|int|null $default

默认值。

返回值
string|int|null

_foreignOnClause() ¶ protected

_foreignOnClause(string $on): string

为外键生成 ON 子句。

参数
string $on

on 子句

返回值
string

_getTypeSpecificColumnSql() ¶ protected

_getTypeSpecificColumnSql(string $columnType, Cake\Database\Schema\TableSchemaInterface $schema, string $column): string|null

尝试使用匹配的数据库类型为表中的单个列生成 SQL 片段。

参数
string $columnType

列类型。

Cake\Database\Schema\TableSchemaInterface $schema

列所在的表模式实例。

string $column

列的名称。

返回值
string|null

addConstraintSql() ¶ public

addConstraintSql(Cake\Database\Schema\TableSchema $schema): array

生成将外键约束添加到表的 SQL 查询

SQLite 不支持在现有表中添加约束,因此此方法为空操作。

参数
Cake\Database\Schema\TableSchema $schema

包含外键约束的表实例。

返回值
array

columnSql() ¶ public

columnSql(Cake\Database\Schema\TableSchema $schema, string $name): string

为表中的单个列生成 SQL 片段。

参数
Cake\Database\Schema\TableSchema $schema

包含该列的表实例。

string $name

列的名称。

返回值
string
抛出
Cake\Database\Exception\DatabaseException
当列类型未知时。

constraintSql() ¶ public

constraintSql(Cake\Database\Schema\TableSchema $schema, string $name): string

生成用于定义表约束的 SQL 片段。

请注意,整数主键将返回 ''。这是故意的,因为 Sqlite 要求在列定义中定义整数主键。

参数
Cake\Database\Schema\TableSchema $schema

包含该列的表实例。

string $name

列的名称。

返回值
string

convertColumnDescription() ¶ public

convertColumnDescription(Cake\Database\Schema\TableSchema $schema, array $row): void

将字段描述结果转换为抽象模式字段。

参数
Cake\Database\Schema\TableSchema $schema
array $row
返回值
void

convertForeignKeyDescription() ¶ public

convertForeignKeyDescription(Cake\Database\Schema\TableSchema $schema, array $row): void

将外键描述转换为 Table 对象上的约束。

参数
Cake\Database\Schema\TableSchema $schema
array $row
返回值
void

convertIndexDescription() ¶ public

convertIndexDescription(Cake\Database\Schema\TableSchema $schema, array $row): void

将索引描述结果转换为抽象模式索引或约束。

由于 SQLite 没有方法来获取所有索引的元数据,因此此处会执行额外的查询。Sqlite 约束名称不稳定,约束的名称将与用于创建表的名称不匹配。这是 Sqlite 元数据功能的限制。

参数
Cake\Database\Schema\TableSchema $schema

要附加索引或约束的表对象。

array $row

来自 describeIndexSql 的行数据。

返回值
void

convertOptionsDescription() ¶ public

convertOptionsDescription(Cake\Database\Schema\TableSchema $schema, array $row): void

将选项数据转换为表选项。

参数
Cake\Database\Schema\TableSchema $schema

表实例。

array $row

数据行。

返回值
void

createTableSql() ¶ public

createTableSql(Cake\Database\Schema\TableSchema $schema, list<string> $columns, list<string> $constraints, list<string> $indexes): list<string>

生成创建表的 SQL 语句。

参数
Cake\Database\Schema\TableSchema $schema
list<string> $columns
list<string> $constraints
list<string> $indexes
返回值
list<string>

describeColumnSql() ¶ public

describeColumnSql(string $tableName, array<string, mixed> $config): array

生成描述表的 SQL 语句。

参数
string $tableName
array<string, mixed> $config
返回值
array

describeForeignKeySql() ¶ public

describeForeignKeySql(string $tableName, array<string, mixed> $config): array

生成描述表中外键的 SQL 语句。

参数
string $tableName
array<string, mixed> $config
返回值
array

describeIndexSql() ¶ public

describeIndexSql(string $tableName, array<string, mixed> $config): array

生成描述表中索引的 SQL 语句。

参数
string $tableName
array<string, mixed> $config
返回值
array

describeOptionsSql() ¶ public

describeOptionsSql(string $tableName, array<string, mixed> $config): array

生成描述表选项的 SQL 语句

参数
string $tableName

表名。

array<string, mixed> $config

连接配置。

返回值
array

dropConstraintSql() ¶ public

dropConstraintSql(Cake\Database\Schema\TableSchema $schema): array

生成从表中删除外键约束所需的 SQL 查询

SQLite 不支持在现有表中删除约束,因此此方法为空操作。

参数
Cake\Database\Schema\TableSchema $schema

包含外键约束的表实例。

返回值
array

dropTableSql() ¶ public

dropTableSql(Cake\Database\Schema\TableSchema $schema): array

生成删除表的 SQL 语句。

参数
Cake\Database\Schema\TableSchema $schema

模式实例

返回值
array

hasSequences() ¶ public

hasSequences(): bool

返回此 SQLite 连接中是否存在任何包含序列的表

返回值
bool

indexSql() ¶ public

indexSql(Cake\Database\Schema\TableSchema $schema, string $name): string

为表中的单个索引生成 SQL 片段。

参数
Cake\Database\Schema\TableSchema $schema
string $name
返回值
string

listTablesSql() ¶ public

listTablesSql(array<string, mixed> $config): array

生成列出表和视图的 SQL 语句。

参数
array<string, mixed> $config

用于获取表的连接配置。

返回值
array

listTablesWithoutViewsSql() ¶ public

listTablesWithoutViewsSql(array<string, mixed> $config): array<mixed>

生成列出表的 SQL 语句,不包括所有视图。

参数
array<string, mixed> $config

用于获取表的连接配置。

返回值
array<mixed>

normalizePossiblyQuotedIdentifier() ¶ protected

normalizePossiblyQuotedIdentifier(string $value): string

从标识符中删除可能的转义字符和周围的引号。

参数
string $value

要标准化的标识符。

返回值
string

possiblyQuotedIdentifierRegex() ¶ protected

possiblyQuotedIdentifierRegex(string $identifier): string

生成一个正则表达式来匹配可能用任何支持的引号引起来或不引起来的标识符。

参数
string $identifier

要匹配的标识符。

返回值
string

truncateTableSql() ¶ public

truncateTableSql(Cake\Database\Schema\TableSchema $schema): array

生成截断表的 SQL 语句。

参数
Cake\Database\Schema\TableSchema $schema
返回值
array

属性详情

$_driver ¶ protected

正在使用的驱动程序实例。

类型
Cake\Database\Driver

$_hasSequences ¶ protected

此 SQLite 连接中是否存在任何包含序列的表。

类型
bool
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题 (Github)
  • 面包店
  • 特色资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻
  • 领英
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成