gpt4 book ai didi

php - 如何使用迁移插件将 tinyint 添加到 cakephp 3 中的数据库字段?

转载 作者:可可西里 更新时间:2023-11-01 00:19:32 25 4
gpt4 key购买 nike

我正在使用 cakephp 3 迁移插件来设计数据库。我想将限制为 1status 字段 tinyint 添加到字段中,我尝试了以下但没有任何结果。

尝试 1.(失败)

$table->addColumn('status', 'smallinteger', [
'default' => 0,
'limit' => 1,
'null' => false,
]);

尝试 2.(失败)

$table->addColumn('status', 'tinyint', [
'default' => 0,
'limit' => 1,
'null' => false,
]);

我找不到任何相同的文档,可能在那里,我遗漏了一些东西 Docs Link

最佳答案

添加 bool 类型的字段添加长度为 1 的 tinyint 列

$table
->addColumn('status', 'boolean', [
'default' => false,
'null' => false,
]);

关于php - 如何使用迁移插件将 tinyint 添加到 cakephp 3 中的数据库字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34946307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com