mysql - 在 codeigniter 迁移中向列添加注释

标签 mysql codeigniter

我正在为我的应用程序编写大量数据库迁移脚本。我想为专栏添加评论,以便其他人可以轻松识别专栏的内容。一种选择是编写普通的 SQL 查询并添加注释。但是有没有办法在迁移脚本中添加这些注释?

$this->dbforge->add_field(array(
  'post_id' => array(
    'type' => 'INT',
    'constraint' => 11,
    'unsigned' => true,
    'auto_increment' => true,
    'comment' => 'Unique post id'
  ),
  'user_id' => array(
    'type' => 'INT',
    'constraint' => 11,
    'unsigned' => true,
  ),
  'group_id' => array(
    'type' => 'INT',
    'constraint' => 11,
    'unsigned' => true,
  ),
  'source' => array(
    'type' => 'VARCHAR',
    'constraint' => 20
  ),
  'data' => array(
    'type' => 'TEXT',
  ),
  'created' => array(
    'type' => 'INT',
    'constraint' => 11,
    'unsigned' => true,
  ),
  'updated' => array(
    'type' => 'INT',
    'constraint' => 11,
    'unsigned' => true,
  ),
  'status' => array(
    'type' => 'INT',
    'constraint' => 1,
    'unsigned' => true,
  )
));

这是我编写的基本代码。可能有一些语法错误。但我只是复制粘贴它。

谁能帮忙。

最佳答案

CodeIgniter 在 3.0 版本中添加了这个功能。您可以使用“评论”键添加评论:

'first_name' => [
    'type'       => 'VARCHAR',
    'constraint' => 45,
    'null'       => false,
    'comment' => 'Put the field comment here',
]

关于mysql - 在 codeigniter 迁移中向列添加注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16620650/

相关文章:

mysql - 如果我不知道字段名称,例如在选择查询中简单地使用 * ,是否可以替换 null

php - MySQL 在 IN() 中的参数后排序

php - 使用 php codeigniter 显示来自 mysql 数据库的数据时出错

php - 对于具有 Cocoa 和 JS 客户端的 Web 服务来说,最简单的数据交换格式是什么?

php - 在sql和codeigniter中查询和存储数组

mysql - Laravel 5.1 Eloquent orWhere 子查询

php - 如何在单个 PHP 文件中使用不同的表单?

php - 如何使用 CodeIgniter 获取浏览器和平台信息?

php - Codeigniter 的邮件内容始终被包装

mysql - 在 phpmyadmin 中导入时如何跳过重复记录