I have a table "emailsettings" which has a "belongsTo" relationship with table "users".
emailsettings has the following columns:
- user_id (INT)
- subscribed (NULL, 0 or 1)
- newsletter (NULL, 0 or 1)
- notifications (NULL, 0 or 1)
My problem is, I'm not able to update the entries, CakePHP always tries to INSERT a new row, even if I do $this->Emailsetting->user_id = 1.
Is it possible that an associated table needs an "id" primaryKey or can I force CakePHP to update an entry if I have the "user_id" (adding an id primaryKey doesn't make sense to me, so I figure there has to be an issue with my setup).
Emailsetting.php
<?php
class Emailsetting extends AppModel {
public $name = 'Emailsetting';
public $belongsTo = array('User' => array('className' => 'User', 'foreignKey' => 'user_id'));
public $useTable = 'email_settings';
}
User.php
<?php
class User extends AppModel {
public $name = 'User';
public $hasOne = array('Profile', 'Emailsetting');
}