简体   繁体   English

如何使用codeIgniter迁移定义复合主键?

[英]How to define composite primary key using codeIgniter migrations?

i convert my database to migrations successfully, except the following line: 我将数据库成功转换为迁移,但以下行除外:

 PRIMARY KEY (`key_id`,`user_id`);

Currently i doing it as: 目前我这样做是:

$this->dbforge->add_key('key_id,user_id',TRUE);

but no Luck. 但没有运气。 gives the following Error: 给出以下错误:

 Error Number: 1072<p>Key column 'key_id,user_id' doesn't exist</p>

can anyone help? 有人可以帮忙吗? sorry for English Grammar and if i am not clear. 对不起,英语语法,如果我不清楚。

Thanks i found the solution my self: 谢谢,我找到了自己的解决方案:

$this->dbforge->add_key('key_id', TRUE);
$this->dbforge->add_key('user_id', TRUE);

here is the source link 这是源链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM