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.
Orm
How can I set multiple primary keys at creating new record?
mantinia
January 2013
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?
mantinia
January 2013
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));
Harro
January 2013
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?
mantinia
January 2013
Yes, first one is not working.
An error occurred at "$obj->primary_key = 1;" line.
I'm using 1.4.
Harro
January 2013
Accepted Answer
Can you give the complete backtrace of the error?
This error was fixed before 1.4.
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
January 2013
mantinia
January 2013