"HasOne" relationship, the problem is that I can't implement it. The
problem is like this
I have a users table:
id integer auto increment primary
firstname varchar(45)
lastname varchar(45)
also I have a userinformations table
id integer auto increment primary
sss_number varchar(45)
birthday datetime
user_id integer
I want this to have a one to one relationship
so what I did in the userinformations_controller.php
class UserinformationsController extends AppController
{
var $name = 'Userinformations';
var $scaffold;
}
in the userinformation.php
class Userinformation extends AppModel
{
var $ame = 'Userinformation';
var $belongsTo = array('User');
}
in the users_controller.php
class UsersController extends AppController
{
var $name = 'User';
var $scaffold;
}
in the user.php
class User extends AppModel
{
var $name = 'User';
var $hasOne = array('Userinformation');
}
After doing that, I add new users to my users table and its
done....The problem now is when I insert records on the
userinformations table, I cant insert 2 or more user_id in the
userinformations table. So I think the problem is on my table cause my
userinformations table has an auto_increment id and also the primary
key. So what I want to do is to delete the id in the userinformations
table and then make the user_id a primary key so, it will have a one
to one relationship with the user table.
Am I right? Give me some advice on how to do it correctly.
Good day.....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment