Trigger depending on another trigger in different table

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

Trigger depending on another trigger in different table

Postby meta » Wed May 21, 2008 8:56 am

Could I have a trigger in one tables delegate class depending on another trigger in another tables delegate class?

An example:

I have an afterSave trigger in the dc of the first table which automatically populates fields in the second table. This works well.

If I now have a beforeInsert trigger in the second tables dc it only works if I insert fields in the second table directly.

Can I make it so that this also works automatically? Kind of a chain-reaction.

Thank you
Markus
meta
 
Posts: 30
Joined: Mon Nov 12, 2007 8:30 am
Location: Berlin, Germany

Postby shannah » Wed May 21, 2008 11:14 am

The xataface triggers are called iff you use the xataface api for inserting the records.

e.g. In table1's delegate class:

Code: Select all
function afterInsert(&$record){
    // Insert a record into table2 so that table2's triggers are NOT called
    $res = mysql_query("insert into table2 ....", df_db());


    // Insert a record into table2 so that table2's triggers ARE called
    $rec2 = new Dataface_Record('table2', array());
    $rec2->setValues( array(
        'col1' => 'val1',
        'col2' => 'val2',
        ...
    ));
    $rec2->save();
}



Hope this helps.

-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 29 guests

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