Is there a way to get field => value pairs from a subselect in MySQL? -
I am considering implementing the audit trail in an app as best, which is supported by MySQL. Some systems rely on the same database and tables, so I thought that the trigger would be the best solution.
However, I do not want to manually write a trigger for each table, so I'm automatically seeing each entry / log field name and data to be deleted.
Something like this:
Include in 'audit' SET` table_name` = 'jobs', `table_key` = old. `Id`,` changed_it` = now (), `notes` = (SELECT * FROM NEW);
However, the subtype will return a line result set, which can not be treated as a string. I want a function that takes that line and converts it to:
"id = 1, name = 'something', another_field = 'data'"
or something like that.
Edit: The main point is that I do not want to type in each field in each table. There are more than 120 tables, and some have> 100 fields, if it is not possible in MySQL, I think I would write a little program to spin on each table and field and generate SQL for me.
select CONCAT ('id =', id, ', name =' '', Name, '' ', another_field =' '', data, '' ') from new to
Comments
Post a Comment