I have been trying to implement the idea of using one form to update many tables. I used Shannah third advice of creating a dummy table with the exact fields that you want on the form. Then create an afterInsert() trigger on this table to copy the values to the appropriate corresponding tables. from http://xataface.com/forum/viewtopic.php?t=4791&sid=04984b7e9696db82d714443246ea7c8c
I managed to get the first bit working but it comes to copying the value of an auto-increment id as a foriegn key into a different table I get an error. Can someone help please. Here is my first piece of code that I used. i get the error in line 34 (in BOLD):
class tables_InputData {
function afterInsert(&$record){
// copy appropriate values to table supplier
$supplierRec = new Dataface_Record('supplier', array());
$supplierRec->setValues(
$record->vals(array('NULL','Name'))
);
$supplierRec->save();
// copy appropriate values to table unit
$unitRec = new Dataface_Record('unit', array());
$unitRec->setValues(
$record->vals(array('NULL','Unit'))
);
$unitRec->save();
// copy appropriate values to table category
$categoryRec = new Dataface_Record('category', array());
$categoryRec->setValues(
$record->vals(array('NULL','Category'))
);
$categoryRec->save();
// copy appropriate values to table subcategory
$subcategoryRec = new Dataface_Record('subcategory', array());
$subcategoryRec->setValues(
$record->vals(array('NULL','Subcategory'))
);
$subcategoryRec->setValue('category_idcategory', $r3Rec->val('idcategory'));
$subcategoryRec->save();
// If there was an auto-increment id from table_1 that needs
// to be stored in the record for table 2 as a foreign key, add it.
I think hat there is something wrong in line 34, I am not sure if the table name and field name are OK or in the right sequence.
Any help is appreciated thank you.
Mico