Hi ALL,
I have created two tables in mysql to store user details.
CREATE TABLE IF NOT EXISTS users
(
id
int(11) NOT NULL auto_increment,
user_name
CHAR( 20 ) default NULL,
password
varchar(255) default NULL,
recovery_question
varchar(255) default NULL,
recovery_answer
varchar(255) default NULL,
user_type
varchar(255) NOT NULL,
status
tinyint(1) default NULL,
email
varchar(255) NOT NULL,
create_date
TIMESTAMP NOT NULL,
update_date
TIMESTAMP NOT NULL,
PRIMARY KEY (id
),
UNIQUE INDEX ( user_name
,user_type
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
AUTO_INCREMENT=5 ;# MySQL returned an empty result set (i.e. zero rows).
CREATE TABLE IF NOT EXISTS personal_details
(
id
int(11) NOT NULL auto_increment,
user_id
varchar(255) NOT NULL,
title
varchar(5) default NULL,
first_name
varchar(20) default NULL,
last_name
varchar(20) default NULL,
current_location
varchar(255) default NULL,
phone_number
int(10) default NULL,
mobile_number
int(10) default NULL,
national_id_or_passport_no
varchar(255) default NULL,
create_date
TIMESTAMP NOT NULL,
update_date
TIMESTAMP NOT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
AUTO_INCREMENT=1;# MySQL returned an empty result set (i.e. zero rows).
in may application when the user enter the login details he will be
validated and directed to this home page where his personal data will
from the personal_details will be displayed.
to retrieve data from the user table i used the following command
<% @user = User.find_first(["Id = "+@u_id]) %>
when it come to retrieve data from the personal_details table i used the
same command like
<% @user = EmployerRepresentativeDetail.find_first(["user_id =
"+@u_id]) %>
so i want to know instead of using like this is their a way to get the
whole data’s in different tables that belongs to a one use.
Also another prob i have is have a give a option to edit his personal
details. where i have taken all the fields in the above two tables in to
one page and allow to edit the and save it. at this point i faces
problem like how to validate and save the things that belong to two
different table and where the validation happen in two different models.
so plssss need some advice from u All…