Help Needed

A place for users and developers of the Xataface to discuss and receive support.

Help Needed

Postby mico » Sun Apr 12, 2009 9:47 pm

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
mico
 
Posts: 8
Joined: Fri Mar 27, 2009 3:13 am

Postby shannah » Mon Apr 13, 2009 12:35 am

what was the actual error message?
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby mico » Mon Apr 13, 2009 12:53 pm

Fatal error: Call to a member function val() on a non-object in /home/postweb/public_html/dentalx/tables/InputData/InputData.php on line 34
mico
 
Posts: 8
Joined: Fri Mar 27, 2009 3:13 am

Postby shannah » Mon Apr 13, 2009 5:53 pm

That means that you are trying to call a method on an variable that isn't an object. In this case it looks like the $r3Rec variable is null. I don't see where this has been set before your calling its val() method.

_Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved