类 SqliteSchemaDialect
Sqlite 的模式管理/反射功能
属性概述
-
$_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|nulladdConstraintSql() ¶ public
addConstraintSql(Cake\Database\Schema\TableSchema $schema): array
生成将外键约束添加到表的 SQL 查询
SQLite 不支持在现有表中添加约束,因此此方法为空操作。
参数
-
Cake\Database\Schema\TableSchema$schema 包含外键约束的表实例。
返回值
arraycolumnSql() ¶ 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 列的名称。
返回值
stringconvertColumnDescription() ¶ public
convertColumnDescription(Cake\Database\Schema\TableSchema $schema, array $row): void
将字段描述结果转换为抽象模式字段。
参数
-
Cake\Database\Schema\TableSchema$schema -
array$row
返回值
voidconvertForeignKeyDescription() ¶ public
convertForeignKeyDescription(Cake\Database\Schema\TableSchema $schema, array $row): void
将外键描述转换为 Table 对象上的约束。
参数
-
Cake\Database\Schema\TableSchema$schema -
array$row
返回值
voidconvertIndexDescription() ¶ public
convertIndexDescription(Cake\Database\Schema\TableSchema $schema, array $row): void
将索引描述结果转换为抽象模式索引或约束。
由于 SQLite 没有方法来获取所有索引的元数据,因此此处会执行额外的查询。Sqlite 约束名称不稳定,约束的名称将与用于创建表的名称不匹配。这是 Sqlite 元数据功能的限制。
参数
-
Cake\Database\Schema\TableSchema$schema 要附加索引或约束的表对象。
-
array$row 来自
describeIndexSql的行数据。
返回值
voidconvertOptionsDescription() ¶ public
convertOptionsDescription(Cake\Database\Schema\TableSchema $schema, array $row): void
将选项数据转换为表选项。
参数
-
Cake\Database\Schema\TableSchema$schema 表实例。
-
array$row 数据行。
返回值
voidcreateTableSql() ¶ 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
返回值
arraydescribeForeignKeySql() ¶ public
describeForeignKeySql(string $tableName, array<string, mixed> $config): array
生成描述表中外键的 SQL 语句。
参数
-
string$tableName -
array<string, mixed>$config
返回值
arraydescribeIndexSql() ¶ public
describeIndexSql(string $tableName, array<string, mixed> $config): array
生成描述表中索引的 SQL 语句。
参数
-
string$tableName -
array<string, mixed>$config
返回值
arraydescribeOptionsSql() ¶ public
describeOptionsSql(string $tableName, array<string, mixed> $config): array
生成描述表选项的 SQL 语句
参数
-
string$tableName 表名。
-
array<string, mixed>$config 连接配置。
返回值
arraydropConstraintSql() ¶ public
dropConstraintSql(Cake\Database\Schema\TableSchema $schema): array
生成从表中删除外键约束所需的 SQL 查询
SQLite 不支持在现有表中删除约束,因此此方法为空操作。
参数
-
Cake\Database\Schema\TableSchema$schema 包含外键约束的表实例。
返回值
arraydropTableSql() ¶ public
dropTableSql(Cake\Database\Schema\TableSchema $schema): array
生成删除表的 SQL 语句。
参数
-
Cake\Database\Schema\TableSchema$schema 模式实例
返回值
arrayindexSql() ¶ public
indexSql(Cake\Database\Schema\TableSchema $schema, string $name): string
为表中的单个索引生成 SQL 片段。
参数
-
Cake\Database\Schema\TableSchema$schema -
string$name
返回值
stringlistTablesSql() ¶ public
listTablesSql(array<string, mixed> $config): array
生成列出表和视图的 SQL 语句。
参数
-
array<string, mixed>$config 用于获取表的连接配置。
返回值
arraylistTablesWithoutViewsSql() ¶ public
listTablesWithoutViewsSql(array<string, mixed> $config): array<mixed>
生成列出表的 SQL 语句,不包括所有视图。
参数
-
array<string, mixed>$config 用于获取表的连接配置。
返回值
array<mixed>normalizePossiblyQuotedIdentifier() ¶ protected
normalizePossiblyQuotedIdentifier(string $value): string
从标识符中删除可能的转义字符和周围的引号。
参数
-
string$value 要标准化的标识符。
返回值
stringpossiblyQuotedIdentifierRegex() ¶ protected
possiblyQuotedIdentifierRegex(string $identifier): string
生成一个正则表达式来匹配可能用任何支持的引号引起来或不引起来的标识符。
参数
-
string$identifier 要匹配的标识符。
返回值
stringtruncateTableSql() ¶ public
truncateTableSql(Cake\Database\Schema\TableSchema $schema): array
生成截断表的 SQL 语句。
参数
-
Cake\Database\Schema\TableSchema$schema
返回值
array