Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Primary Key as Foreign Key too Has_One relationships problem
  • Models: http://scrp.at/bHJ My 'users_settings' table has a primary key ('user_id') which is also a foreign key that references the 'users' autoincremented primary key ('user_id') The following code :
    $user->name = 'blabla';
    $user->settings = new \Model\UserSettings();
    $user->save();
    
    or
    $user->name = 'blabla';
    $user->save();
    $user->settings = new \Model\UserSettings();
    $user->save();
    
    results in an insert statement where the 'user_settings' user_id is not set, and causes a not null constraint check error. Is it normal ? Has the ORM been designed with the fact that each table should have its own autoincrement primary key ?
  • Oh it's normal...
    See: http://fuelphp.com/forums/topics/view/9975 Since my database relations are simple and I don't really want to redesign my database by removing composite primary keys and PK as FK (like above) so I'll give up the ORM and use the Model_Crud instead.

Howdy, Stranger!

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

In this Discussion