Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
How can I set a field as a primary key in a migration?
JeanAlesi
August 2015
I want to create a table with a composite primary key made out of foreign keys...
How can I do that?
E.g:
TABLE:
column_1 (primary, foreign_key)
column_2 (primary, foreign_key)
column_3 ( )
Harro
August 2015
Accepted Answer
If you're planning on using the ORM, you can not have foreign keys as part of the primary key. The ORM sometimes what's to set them to NULL which is not handy for a PK.
You create a table using DBUtil::create_table (see
http://docs.fuelphp.com/classes/database/dbutil.html#/method_create_table
), if you have a composite PK, simply pass more than one column name in the array of primary key columns...
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
August 2015