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 multiple primary keys at creating new record?
  • There a table has multiple primary keys (not auto_incremented).
    I want to create a record with orm but it can't be.
    It says "Primary key cannot be changed" as error occurred.
    Off course I know, but it must set the primary keys at first time.
    How can I do?
  • It resolved myself.

    It doesn't work as below.
    $obj = new Model_Obj();
    $obj->primary_key = 1;
    $obj->primary_key2 = 1;

    It should be:
    $obj = Model_Obj::forge(array('primary_key' => 1, 'primary_key2' => 1));

  • The first one should work to.

    As long as a model is in "new" state, AND no value has been assigned to the primary key column(s), you should be able to assign it like that too.

    Are you use that exact syntax isn't working? And if so, which version of Fuel are you on?
  • Yes, first one is not working.
    An error occurred at "$obj->primary_key = 1;" line.

    I'm using 1.4.

  • HarroHarro
    Accepted Answer
    Can you give the complete backtrace of the error?

    This error was fixed before 1.4.

Howdy, Stranger!

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

In this Discussion