Do something whenever value of a field is changed

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

Do something whenever value of a field is changed

Postby hhkilis » Mon Apr 02, 2012 6:21 am

Hi,

I want Xataface to execute some commands whenever value of a field is changed.

How can I handle this?

I know that there are two triggers available to be implemented in a table's delegate class. (AfterUpdate and AfterSave) Problem is I don't know how to understand that value of a field is changed during execution of one of these triggers since I can only see the last value either updated or not from the database?
hhkilis
 
Posts: 15
Joined: Mon Feb 27, 2012 5:49 am

Re: Do something whenever value of a field is changed

Postby shannah » Mon Apr 02, 2012 9:40 am

In the beforeSave, beforeUpdate, and beforeInsert triggers you can check for changed values.

e.g.
Code: Select all
beforeSave($record){
    if ( $record->valueChanged('myfield') ){
        // Do something .. the value for the field 'myfield' has been changed.
    }
}
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Do something whenever value of a field is changed

Postby hhkilis » Tue Apr 03, 2012 3:36 am

Thanks
hhkilis
 
Posts: 15
Joined: Mon Feb 27, 2012 5:49 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 9 guests

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