CodeIgniter - 其他dbforge / migration字段 [英] CodeIgniter - Additional dbforge / migration fields

查看:446
本文介绍了CodeIgniter - 其他dbforge / migration字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我有用[0]丢个板砖[0]引用|举报|编辑删除管理回复次数:7我想知道是否有人可以帮我把以下内容翻译成正确的dbforge-> add_field数组



我需要以下2

 `last_login` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 


$ b b

 `created` datetime NOT NULL DEFAULT'0000-00-00 00:00:00'

我已经从tank_auth库的SQL插入语句复制了这些。


$



但是现在我想把它加入迁移。

方案

您可以使用

  $ this-> dbforge-> add_field last_login TIMESTAMP'); 

  $ data = array(
'type'=>'TIMESTAMP'
);

此自动插入ON UPDATE CURRENT_TIMESTAMP


Im having trouble figuring out this migrations business for CodeIgniter ... I cant find any decent documentation that explains additional field elements like current_timestamp, default datetime values etc etc

I was wondering if someone could help me out to translate the following into proper dbforge->add_field arrays

I need the following 2

`last_login` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

and

`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'

I have copied these from the SQL insert statement from the tank_auth library.

But i want to put it into migrations now.

Cheers,

解决方案

for number 1 you can use

$this->dbforge->add_field('last_login TIMESTAMP');

or

$data = array(
 'type' => 'TIMESTAMP'
);

This auto inserts ON UPDATE CURRENT_TIMESTAMP

这篇关于CodeIgniter - 其他dbforge / migration字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆