Page 1 of 1

Do something whenever value of a field is changed

PostPosted: Mon Apr 02, 2012 6:21 am
by hhkilis
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?

Re: Do something whenever value of a field is changed

PostPosted: Mon Apr 02, 2012 9:40 am
by shannah
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.
    }
}

Re: Do something whenever value of a field is changed

PostPosted: Tue Apr 03, 2012 3:36 am
by hhkilis
Thanks