On PreEdit question
On PreEdit question
nessinits
Posts: 86Questions: 27Answers: 0
Hi,
This is a PHP library question. I want to create a mechanism that makes notifications of the modified data. Is there a simpel solution to determine the difference between the database data and the posted data before it written to the database? Do I need to query the database or is the data already available?
Kind regards,
nessinits
This question has accepted answers - jump to:
This discussion has been closed.
Answers
The easiest option would be to use the
changed
option of theform-options
object. That way the client-side will only submit the data that has actually changed value.If you want to do something more complex like a proper diff, then yes, you'd need to read the old data from the database first.
Allan
Thanks Allan,
It's the more complex thing I want to do. It's not the answer I hoped for, but it's an answer I can work with.
Best regards,
nessinits
@nessinits
Here is some sample code using Editor's database handler which is available here. Took me a while to figure out how to use it. Based on this you could select the record and diff it with what is coming from the client:
fetch all and get the row count:
another one with DELETE
I guess one other option would be to use
initEdit
to copy the values of the form when editing on a row is triggered into hidden "dummy" fields. Then when the form is submitted you would have both the data as it was before editing and the data after editing. Any diff could then be done between them. Didn't think of that last night - sorry!Allan