类 PostgresSchemaDialect
Postgres 的模式管理/反射功能。
常量
-
DEFAULT_SRID ¶
4326
属性摘要
-
$_driver protected
Cake\Database\Driver正在使用的驱动程序实例。
方法摘要
-
__construct() public
构造函数
-
_applyTypeSpecificColumnConversion() protected
尝试使用匹配的数据库类型将 SQL 列定义转换为抽象类型定义。
-
_convertColumn() protected
将列定义转换为抽象类型。
-
_convertConstraint() protected
将约束添加到模式对象中或更新模式对象中的约束。
-
_convertConstraintColumns() protected
将外键约束引用转换为有效的字符串化列表
-
_convertOnClause() protected
将字符串 on 子句转换为抽象 on 子句。
-
_defaultValue() protected
操作默认值。
-
_foreignOnClause() protected
为外键生成 ON 子句。
-
_getTypeSpecificColumnSql() protected
尝试使用匹配的数据库类型为表中的单个列生成 SQL 片段。
-
_keySql() 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。
-
indexSql() public
为表中的单个索引生成 SQL 片段。
-
listTablesSql() public
生成列出表和视图的 SQL。
-
listTablesWithoutViewsSql() public
生成列出表 (不包括所有视图) 的 SQL。
-
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当列无法解析时。
_convertConstraint() ¶ protected
_convertConstraint(Cake\Database\Schema\TableSchema $schema, string $name, string $type, array $row): void
将约束添加到模式对象中或更新模式对象中的约束。
参数
-
Cake\Database\Schema\TableSchema$schema 要更新的表。
-
string$name 索引名称。
-
string$type 索引类型。
-
array$row 要使用其更新的元数据记录。
返回值
void_convertConstraintColumns() ¶ protected
_convertConstraintColumns(list<string>|string $references): string
将外键约束引用转换为有效的字符串化列表
参数
-
list<string>|string$references 外键约束语句的引用列
返回值
string_convertOnClause() ¶ protected
_convertOnClause(string $clause): string
将字符串 on 子句转换为抽象 on 子句。
参数
-
string$clause
返回值
string_defaultValue() ¶ protected
_defaultValue(string|int|null $default): string|int|null
操作默认值。
Postgres 在默认值中包含序列数据和强制转换信息。我们需要删除这些信息。
参数
-
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_keySql() ¶ protected
_keySql(string $prefix, array<string, mixed> $data): string
生成键 SQL 片段的辅助方法。
参数
-
string$prefix 键前缀
-
array<string, mixed>$data 键数据。
返回值
stringaddConstraintSql() ¶ public
addConstraintSql(Cake\Database\Schema\TableSchema $schema): array
生成将外键约束添加到表的 SQL 查询。
参数
-
Cake\Database\Schema\TableSchema$schema
返回值
arraycolumnSql() ¶ public
columnSql(Cake\Database\Schema\TableSchema $schema, string $name): string
为表中的单个列生成 SQL 片段。
参数
-
Cake\Database\Schema\TableSchema$schema -
string$name
返回值
stringconstraintSql() ¶ public
constraintSql(Cake\Database\Schema\TableSchema $schema, string $name): string
生成定义表约束的 SQL 片段。
参数
-
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
将索引描述结果转换为抽象模式索引或约束。
参数
-
Cake\Database\Schema\TableSchema$schema -
array$row
返回值
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 查询。
参数
-
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>truncateTableSql() ¶ public
truncateTableSql(Cake\Database\Schema\TableSchema $schema): array
生成截断表的 SQL。
参数
-
Cake\Database\Schema\TableSchema$schema
返回值
array