aniesh82 Posted October 31, 2008 Share Posted October 31, 2008 Hi, I would like to hear from you all about the Logging of all database changes. I have lots of tables in the database and many user have the permissions to edit these details. But the Super Admin, can view all the changes, like the old data, new data, who changed, changed date & time. I need these data to be logged whenever someone makes changes and able to see in future also. Any package is available for doing this task ? Also, if you have any great idea about this, please share that also. Thank You. Link to comment https://forums.phpfreaks.com/topic/130844-logging-of-all-database-changes/ Share on other sites More sharing options...
GuitarGod Posted October 31, 2008 Share Posted October 31, 2008 If you're just looking for a basic way to log the changes and nothing more, then you could probably write a script yourself that logs all the changes in a text file. For example, create a file called 'logs.txt', and place it in an appropriate directory. <?php $sql = 'UPDATE table_name .............'; if ( mysql_query( $sql ) ) { // The table has been changed, so you can update the logs file // First get all the current logs $contents = file_get_contents( 'logs.txt' ); // Create the new log $new_log = 'SQL: '.$sql.' Date: '.date( 'D-m-y etc ..').''; // Open the logs file and write the new log/old logs to it $open = fopen( 'logs.txt', 'w' ); fwrite( $open, $new_log.$contents ); fclose( $open ); } ?> It's not brilliant and I don't know if it works, but you get my point Link to comment https://forums.phpfreaks.com/topic/130844-logging-of-all-database-changes/#findComment-679258 Share on other sites More sharing options...
aniesh82 Posted November 3, 2008 Author Share Posted November 3, 2008 Thank you for your reply. By writing the first records in the logs.txt, this will works and can find out the changes in future. Link to comment https://forums.phpfreaks.com/topic/130844-logging-of-all-database-changes/#findComment-681331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.