Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How can I set a field as a primary key in a migration?
  • 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 (     )
  • HarroHarro
    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...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion