KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
i have a LAPP (linux, apache, postgresql and php) environment, but the question is pretty the same both on Postgres or Mysql. I have an cms app i developed, that handle clients, documents (estimates, invoices, etc..) and other data, structured in 1 postgres DB with many schemas (one for each our customer using the app); let's assume around 200 schemas, each of them used concurrently by 15 people (avg). EDIT : I do have an timestamp field named last_update on every table, and a trigger that update the timestamp every time the row is update. The situation is: People Foo and Bar are editing the document 0001, using a form with every document details. Foo change the shipment details, for example. Bar change the phone numbers, and some items in the document. Foo press the 'Save' button, the app update the db. Bar press the 'Save' button after bar, resending the form with the old shipment details. In the database, the Foo changes have been lost. The situation i want to have: People Foo, Bar, John, Mary, Paoul are editing the document 0001, using a form with every document details. Foo change the shipment details, for example. Bar and the others change something else. Foo press the 'Save' button, the app update the db. Bar and the others get an alert 'Warning! this document has been changet by someone else. Click here to load the actuals data'. I've wondered to use ajax to do this; simply using an hidden field with the id of the document and the last-updated timestamp, every 5 seconds check if the last-updated time is the same and do nothing, else, show the alert dialog box. So, the page check-last-update.php should look something like: <?php //[connect to db, postgres or mysql] $documentId = isset($_POST['document-id']) ? $_POST['document-id'] : 0; $lastUpdateTime =
Tags (comma-separated)
Save Edits
Cancel