markyboy17 Posted January 10, 2012 Share Posted January 10, 2012 I have a mysql table in which will be updated fairly frequently via php code on a form. My question is how do I code a log of the changes made into another table using php or calling a stored procedure from within the database. or if you can think of a better way suggest it. Stored procedure would be more secure if possible. Quote Link to comment https://forums.phpfreaks.com/topic/254707-logs/ Share on other sites More sharing options...
Adam Posted January 10, 2012 Share Posted January 10, 2012 That's not a very clear or simple question. What do you mean by 'log of the changes'? Quote Link to comment https://forums.phpfreaks.com/topic/254707-logs/#findComment-1306038 Share on other sites More sharing options...
markyboy17 Posted January 10, 2012 Author Share Posted January 10, 2012 Hi For explanation purposes lets say i have a table with the field age. if i have an update query in php that gives the ability to change that age i want a bit of code to intercept what the change was and place it in a table or any sort of format where it is clear to understand Sorry for the confusion hope this is clearer Quote Link to comment https://forums.phpfreaks.com/topic/254707-logs/#findComment-1306058 Share on other sites More sharing options...
litebearer Posted January 10, 2012 Share Posted January 10, 2012 Rough idea (I use it on my personal family site. It can be used to notify family members of changes to the site; ie new pics, new relatives, posts to the message section etc)... 1, create a table called ummmm table_actions 2. id, table_name, what_action_what_date 3. Essentially any table has 4 basic actions - add, delete, edit and view 4. write a small function that you include in every script that does one of the things in #3 5. the function (A) sets the table effected, the date and the action; then (B) adds that to the table_actions Quote Link to comment https://forums.phpfreaks.com/topic/254707-logs/#findComment-1306092 Share on other sites More sharing options...
laffin Posted January 10, 2012 Share Posted January 10, 2012 You can use wrapper functions as litebearer suggests, very easy, basic and works well. or using 1 & 2 with MySQL trigger functions More Here Quote Link to comment https://forums.phpfreaks.com/topic/254707-logs/#findComment-1306221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.