CakePHP
  • 文档
    • 手册
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题 (Github)
    • Bakery
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻简报
    • Linkedin
    • 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
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
      • Exception
      • Locator
      • Paging
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

接口 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

列的属性或类型名称。

返回值
$this

baseColumnType() ¶ public

baseColumnType(string $column): string|null

返回提供的列的基本类型名称。这表示更复杂的类所基于的数据库类型。

参数
string $column

要获取基本类型的列名称

返回值
string|null

columns() ¶ public

columns(): list<string>

获取表格中的列名称。

返回值
list<string>

defaultValues() ¶ public

defaultValues(): array<string, mixed>

获取列及其默认值的哈希表。

返回值
array<string, mixed>

getColumn() ¶ public

getColumn(string $name): array<string, mixed>|null

获取表格中的列数据。

参数
string $name

列的名称。

返回值
array<string, mixed>|null

getColumnType() ¶ public

getColumnType(string $name): string|null

返回列类型,如果列不存在则返回 null。

参数
string $name

要获取类型的列。

返回值
string|null

getOptions() ¶ public

getOptions(): array<string, mixed>

获取表格的选项。

表格选项允许您设置特定于平台的表格级别选项。例如,MySQL 中的引擎类型。

返回值
array<string, mixed>

hasColumn() ¶ public

hasColumn(string $name): bool

如果模式中存在列,则返回 true。

参数
string $name

列名称。

返回值
bool

isNullable() ¶ public

isNullable(string $name): bool

检查字段是否可为空。

缺少的列是可空的。

参数
string $name

要获取类型的列。

返回值
bool

name() ¶ public

name(): string

获取表格的名称。

返回值
string

removeColumn() ¶ public

removeColumn(string $name): $this

从表格模式中删除一列。

如果表格中没有定义列,则不会引发错误。

参数
string $name

列的名称

返回值
$this

setColumnType() ¶ public

setColumnType(string $name, string $type): $this

设置列的类型。

参数
string $name

要设置类型的列。

string $type

要设置的列的类型。

返回值
$this

setOptions() ¶ public

setOptions(array<string, mixed> $options): $this

设置表格的选项。

表格选项允许您设置特定于平台的表格级别选项。例如,MySQL 中的引擎类型。

参数
array<string, mixed> $options

要设置的选项,或 null 以读取选项。

返回值
$this

typeMap() ¶ public

typeMap(): array<string, string>

返回一个数组,其中键是模式中的列名称,值是它们的数据库类型。

返回值
array<string, string>
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题 (Github)
  • Bakery
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻简报
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API Docs 生成