php - Detecting field changes - cakePHP -
php - Detecting field changes - cakePHP -
what want
i want see fields on table changed , save name database under edit column.
what have
currently, not much. standard cakephp baked edit view , controller. have done previously, not cakephp. did retrieve record, , if it's different user entered, save name of column edited in edit
column corresponding row.
my question
could tell me how compare user input on database?
behaviors "logable" behavior , store info separately. advice same. "changes" not need set same table. if sense do, though, create own "modified" logable behavior creates "diff" , stores field of selection on same record.
ps: might want take @ revisionbehavior. contains diff algorithm. there whodidit behavior stores user lastly modified record. in same table, though. combined above should trick.
either way:
use callbacks (beforesave/aftersave) on model or (cleaner) behavior calculate diff store diff in separate table or in case in table field.actually writing here job pretty straight-forward. voluntary exercise here write more "generic". maybe want reuse same functionality 1 time again other models in future? copy-and-paste pretty bad style then. goal here create generic piece of code can reuse. if initial code works, seek rewrite generic changesbehavior can attach many models like. can take linked examples or take @ other behaviors out there thought how that.
also can publish behavior in github/plugins.cakephp , give community again. maybe others find useful, too.
php mysql cakephp
Comments
Post a Comment