1

I want to make a log details for my database while a record insert into any table and update any table and delete any record from an table in MYSQL - PHP. Please give me some ideas.

Nisanth
  • 323
  • 6
  • 23
  • [This](http://stackoverflow.com/a/12564435/2518525) might be able to help you. It's called audit tables – Darren May 20 '16 at 06:03
  • If you want to track each mysql operation you can create a txt file named with date and after executing each mysql statement you can update this file. – Afshan Shujat May 20 '16 at 06:06
  • Maybe it's not exactly what you are looking for, but http://dev.mysql.com/doc/refman/5.7/en/query-log.html – Isty001 May 20 '16 at 06:07

2 Answers2

1

You've used laravel tag, so I assume you want to find a 'Laravel way' to do it.

The best practice is to use Eloquent Events.

Each time when Laravel will hit the DB, it will try to run some of these events: creating, created, updating, updated, saving, saved, deleting, deleted, restoring, restored

-ing events are used before hitting DB, -ed events are used right after hitting DB.

Example:

public function boot()
{
    User::created(function () {
        Log::info('User was just created successfully');
    });
}
Alexey Mezenin
  • 148,626
  • 22
  • 267
  • 261
0

Read this Tutorial carefully i think its work for you

http://web.stanford.edu/dept/its/communications/webservices/wiki/index.php/How_to_create_logs_with_PHP

Gorakh Yadav
  • 294
  • 5
  • 17