Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

If your objective is specifically to give your user a friendly “undo” capability, then you could do this by creating any sort of a table in which you can manage to capture a string of values.   (Placing a JSON-encoded text string in a long-text field comes to mind ... I have not had good experiences with mod:://Storable.)

But you have to think it through very carefully, because database records may well be shared.   In any case they may be visible to many different users, who might therefore see a partially-finished record while your user is deciding exactly what she wants to do.   There could also be conflicts if two users start changing the same record.

When my goal is specifically “undo,” one thing that I like to do is to capture the original record values and all of the subsequent changes that the user may make to those values, (only) in the “undo” record stack, which is distinct for each user session.   If the user finally decides to save the record, I compare the existing record to the one that is in the database (to guard against changes by other users), then apply the changes from the latest version in the “undo” stack.   The underlying record does not change until, and unless, the user accepts whatever changes she has made ... thus replicating the behavior that folks are used-to from working with disc documents.   Since you have access to the initial version, the final version, and every change in-between, you can also be pretty “smart” about conflict resolution and so-on.


In reply to Re: Log changes in a database (DBI) by sundialsvc4
in thread Log changes in a database (DBI) by citromatik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-29 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found