php - A better logging design or some SQL magic? -


I am deep in revising some old logging codes which I did not write and wondered about what you did about it Think. This is an event logger that is written in PHP with MySQL, which logs to that message:

  Sara added a user, slick101 mike removed a user, slick101bob One service, payment  

is broken in this way:

  Sarah [user_id] has created a user [message], slick101 [reference_id, reference_table_name] A pair of such table in:  

  log --- id user_id context_id context_table_name message  

please Note that u In the aforementioned example messages "Bob" and "payment" are the IDs for the other tables, it is necessary to include one to get the real name no name.

It seems that the "reference _ table_names" is to find the proper name in the correct table, because only the reference _ id is stored. This would probably be good if a table name is included in the reference_table_name that is stored in such a way:

  select * Log in from log {{reference_table_name}} r at RIID = l I think I'm seeing where he was going with this table layout - how much better it is to store the whole message in one column. (For which the text requires parsing). Now I am thinking .. 

Is there a better way or is it possible to believe in any way?

Cheers

To join on the basis of modeling, You may be looking at the process of two steps:

  1. Get the name of the table from LOG for a special message
  2. Dynamic by creating the actual query as a string Use SQL IE:

    "Select L. * Add from Login" + Tablemap + "R on R.ID = L.Repar_ID"

Not there There are so many values ​​to delete the logs because there is no record to look for deleted.

How much history does the application need?

Do you need to know who did the price in the past for the months / years? If records are required, they should be stored & amp; If you do not need all the history, consider using the following auditing columns on each table:

  • ENTRY_USERID, do not tap
  • ENTRY_TIMESTAMP UPDATE_USERID, tap
  • UPDATE_TIMESTAMP, DATE, NULL
  • These columns allow you to know which Record & amp; When and finally, when it was finally updated and when I prepare audit tables on a matter of case basis, it only depends on the user's performance.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -