HungryMind Posted July 1, 2011 Share Posted July 1, 2011 I want to create a log file on insert, update, delete.I don't want call log function every time when i'm inserting, updating or deleting record.Is there any short method? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 1, 2011 Share Posted July 1, 2011 Other than using a database class to do whatever you want when queries are run, you can also look into setting up logging on MySQL itself and just use the log files that it creates. Link to comment Share on other sites More sharing options...
HungryMind Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks for reply my friend.My Teacher Told Me About PHP Triggers, That Triggers Can Play Action On "Insert", "Delete", Update" Events. But I Don't Know How To Use PHP TRIGGERS? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 5, 2011 Share Posted July 5, 2011 Triggers aren't implemented in PHP, they are implemented in the database. MySQL has triggers, not PHP.http://dev.mysql.com/doc/refman/5.0/en/triggers.html Link to comment Share on other sites More sharing options...
HungryMind Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks For The Link & Info Friend.It's Seems Like Complicated For Me :SBecause I'm Not Professional.So Can We Set Action On Insert, Delete, Update Events Using Triggers?I Just Want To Create a Log Entry Every time On These Events. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 5, 2011 Share Posted July 5, 2011 You can set up triggers in MySQL to do things before or after various queries are executed, but I don't know if logging is one of those things. You should be able to set up MySQL to log all queries though, without using triggers.http://dev.mysql.com/doc/refman/5.1/en/query-log.html Link to comment Share on other sites More sharing options...
HungryMind Posted July 5, 2011 Author Share Posted July 5, 2011 Ooh Great, It's Really Good. Thanks a Lot Friend, You Are Awesome Link to comment Share on other sites More sharing options...
HungryMind Posted July 13, 2011 Author Share Posted July 13, 2011 Thanks For Your Replies Once Again, I've Created My First TRIGGER I'm So Happy, Thank a lot Friends.I've Now One More Question DROP TRIGGER IF EXISTS `catch_insert`//CREATE TRIGGER `catch_insert` BEFORE INSERT ON `books` FOR EACH ROW BEGININSERT INTO testing.trigger (id, email, password) values ('1', 'abc@abc.com', 'pass');END// This Is Working Perfect On Every Time When Ever New Record INSERTS.I Just Want To Create a Log File Using Trigger To Do Same Thing.I Don't Want To Create Records On Database.So Please Guide. Link to comment Share on other sites More sharing options...
justsomeguy Posted July 13, 2011 Share Posted July 13, 2011 Database records are log entries. If you want to save the query to a text file then use the regular MySQL query log, not a trigger. All queries already get saved to the general query log. You can use that log if you're looking for past queries. Link to comment Share on other sites More sharing options...
HungryMind Posted July 14, 2011 Author Share Posted July 14, 2011 Oh Great, Thanks justsomeguy.But! Is It Possible On Any Hosting. I'm Reading About MySQL Query Log, Here I'll Set Up MySQL Configuration. So What Will I Do To Configuration? Link to comment Share on other sites More sharing options...
justsomeguy Posted July 14, 2011 Share Posted July 14, 2011 I don't know if I understand your question. Read the link I posted above to the description about the query log. You may not have access to the log on a shared host, you'll want to ask your host and see if they can set up a log just for your account. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.