MDB2: Automating a database change log
| From: | Charles Mayo | Date: | Wed, 18 Jun 2008 20:25:45 +0000 |
| Subject: | MDB2: Automating a database change log | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-29026@lists.php.net to get a copy of this message | ||
Hi All,
I'm looking for a way to create a database change log for a contract client's office
management system without having to re-code 700+ queries. The change log would record changes made
to each record in selected tables, new records created in those tables, the user performing the
change (available to me in PHP session variables) and the date and time of the change.
It occurred to me that since every query in the system runs through MDB2 there might be some way to
use some of MDB2's functionality to accomplish my goal, and I've been looking at
MDB2's debug functions, wondering if I could use debug data to keep track of record changes.
All I've been able to learn about MDB2's debug function so far is that I can get a list of
all queries run by a script. I'm thinking of trying to write some sort of query parser in PHP
to ferret out each table and record that's been inserted or updated by a script, run a query to
return the modified records and use those results to maintain a change log by comparing each field
to previously-recorded values, but writing even a modestly robust query parser in PHP is likely
beyond my MySQL skillset, so I'm wondering if perhaps someone more knowledgeable about MDB2
could suggest a better/easier way.
Any ideas, suggestions, or pointers would be greatly appreciated.
Thanks,
Chuck