Here is the details of what I did:
I'm implementing a database where I'm keeping records of people of different classes; faculty, staff, and students. These classes share some attributes (last name, first name, phone number, email address, etc.), but not others (faculty have "teaching interests" but students and staff don't, students have a "thesis defense date" but faculty and staff don't, and so on). To me, this looks like a classic case for implementing inheritance. So I decided to take advantage of the "__isa__" directive. I created "people" and "faculty_profile" tables as follows:
CREATE TABLE IF NOT EXISTS `people` (
`id` int(11) NOT NULL auto_increment,
`given_names` varchar(64) NOT NULL default '',
(... yada, yada, yada ...)
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `faculty_profile` (
`people_id` int(11) NOT NULL,
`teaching_interests` text,
(... yada, yada, yada ...)
PRIMARY KEY (`people_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Then I created the field.ini and valueslists.ini for both tables and inserted "__isa__=peope" into the fields.ini file in tables/faculty_proifle. Finally, I updated conf.ini with a faculty=Faculty record under [_tables]
As a test, I manually (i.e., carefully handcrafted, using only the finest ingredients) a record in each of the two tables, updating the faculty.people_id field with the corresponding people.id value. Then I opened the record in XF (things looked good), made a change and saved the data. It worked.
However, if I try to add a record, I get the following error upon clicking Save:
- Code: Select all
Invalid information entered.
- People id is a required field.
Please correct these fields.
So it appears the faculty_profile.people_id field is not getting filled.
I can't fill the faculty_profile.people_id field until the people.id field is filled, and that field doesn't get filled until the record is inserted into the database because it is "auto_increment". But, the record can't be inserted into the database until the faculty_profile.people_id field is field. Classic Catch 22.
I'd appreciate any thoughts or enlightenment on this. Thank-you.