+2  A: 

Use stored procedures for all your updating/inserting/deleting The procedure should take all the arguments it needs to perform the given task plus one argument that will contain the comment. Then just update/insert/delete and make a record (with the comment) in the log table.

ps: can't see how you would be able to use some tool if you need to insert comments (same problem than triggers).

Jan Hančič
Thanks a lot for your quick response. But I am not so good at stored procedures. Also I am not getting an idea of how to get only the changed columns old and new data.Can you suggest any example of such stored procedure for mysql. Thanks again
Enjoy coding
Well you would have to pull the old data from the table and compare each field with the new values. This can be done either in PHP or in the stored procedure.If you don't know stored procedures then I'm afraid your only options is to do this in PHP.
Jan Hančič
+3  A: 

I definitely prefer doing this in application code rather than in the DB. An ORM is wonderful at handling this kind of thing as it gives an easy way of tracking and intercepting changes.

If you have a sensible abstraction over your database access then it should be pretty simple to intercept any database calls in your PHP code and do the logging there. Of course if you are building up SQL manually and then calling the database directly there is no central place for you to log changes.

Jack Ryan
I am building up SQL queries by utility functions in codeigniter which will take data and give sql query string.
Enjoy coding
+1  A: 

phpmyadmin supports database replication and tracking changes since the latest version

knittl
phpmyadmin supports that. God I did not know that. How can I use that to insert all logs into new table as per my requirement?? Please let me know as soon as possible. Thanks a lot in advance
Enjoy coding
http://blog.cihar.com/archives/2009/08/27/summer_of_code_in_phpmyadmin/ gives some insight
knittl
I think PhpMyAdmin logs only the requests done through itself. In that case I need other solution.
Enjoy coding