接口 SchemaInterface
TableSchema 对象使用的接口。
        
    命名空间: Cake\Datasource
    
    
    
      
  
  
        方法摘要
- 
          addColumn() public在表格中添加一列。 
- 
          baseColumnType() public返回提供的列的基本类型名称。这表示更复杂的类所基于的数据库类型。 
- 
          columns() public获取表格中的列名称。 
- 
          defaultValues() public获取列及其默认值的哈希表。 
- 
          getColumn() public获取表格中的列数据。 
- 
          getColumnType() public返回列类型,如果列不存在则返回 null。 
- 
          getOptions() public获取表格的选项。 
- 
          hasColumn() public如果模式中存在列,则返回 true。 
- 
          isNullable() public检查字段是否可为空。 
- 
          name() public获取表格的名称。 
- 
          removeColumn() public从表格模式中删除一列。 
- 
          setColumnType() public设置列的类型。 
- 
          setOptions() public设置表格的选项。 
- 
          typeMap() public返回一个数组,其中键是模式中的列名称,值是它们的数据库类型。 
方法详情
addColumn() ¶ public
addColumn(string $name, array<string, mixed>|string $attrs): $this在表格中添加一列。
属性
列可以有几个属性
- type列的类型。这应该是 CakePHP 的抽象类型之一。
- length列的长度。
- precision存储浮点数和十进制数的小数位数。
- default列的默认值。
- null列是否可以为空。
- fixed列是否为固定长度列。这仅在字符串列中存在/有效。
- unsigned列是否为无符号列。这仅在整数、十进制数、浮点数列中存在/有效。
除了上面的键之外,以下键在某些数据库方言中实现,但并非全部实现
- comment列的注释。
参数
- 
                string$name
- 列的名称 
- 
                array<string, mixed>|string$attrs
- 列的属性或类型名称。 
返回值
$thisbaseColumnType() ¶ public
baseColumnType(string $column): string|null返回提供的列的基本类型名称。这表示更复杂的类所基于的数据库类型。
参数
- 
                string$column
- 要获取基本类型的列名称 
返回值
string|nulldefaultValues() ¶ public
defaultValues(): array<string, mixed>获取列及其默认值的哈希表。
返回值
array<string, mixed>getColumn() ¶ public
getColumn(string $name): array<string, mixed>|null获取表格中的列数据。
参数
- 
                string$name
- 列的名称。 
返回值
array<string, mixed>|nullgetColumnType() ¶ public
getColumnType(string $name): string|null返回列类型,如果列不存在则返回 null。
参数
- 
                string$name
- 要获取类型的列。 
返回值
string|nullgetOptions() ¶ public
getOptions(): array<string, mixed>获取表格的选项。
表格选项允许您设置特定于平台的表格级别选项。例如,MySQL 中的引擎类型。
返回值
array<string, mixed>isNullable() ¶ public
isNullable(string $name): bool检查字段是否可为空。
缺少的列是可空的。
参数
- 
                string$name
- 要获取类型的列。 
返回值
boolremoveColumn() ¶ public
removeColumn(string $name): $this从表格模式中删除一列。
如果表格中没有定义列,则不会引发错误。
参数
- 
                string$name
- 列的名称 
返回值
$thissetColumnType() ¶ public
setColumnType(string $name, string $type): $this设置列的类型。
参数
- 
                string$name
- 要设置类型的列。 
- 
                string$type
- 要设置的列的类型。 
返回值
$thissetOptions() ¶ public
setOptions(array<string, mixed> $options): $this设置表格的选项。
表格选项允许您设置特定于平台的表格级别选项。例如,MySQL 中的引擎类型。
参数
- 
                array<string, mixed>$options
- 要设置的选项,或 null 以读取选项。 
返回值
$thistypeMap() ¶ public
typeMap(): array<string, string>返回一个数组,其中键是模式中的列名称,值是它们的数据库类型。
返回值
array<string, string>