I want to be able to keep a log of every sql statment that edits a specific table, and I think the best way would be with a trigger. However, I don't know how to get the statement that triggers the trigger.
For example if I run:
$sql = "INSERT INTO foo (col_1) VALUES ('bar');"
I want to be able to craft an insert statement like:
$sql = "INS开发者_如何学CERT INTO log (statements) VALUES (INSERT INTO foo (col_1) VALUES ('bar')'
Is this possible with a trigger? I know I can do this easily with php, but I figured that a trigger would have less overhead.
You can't get the statements, only their results / alterations. Consider using a database abstraction- or decorator-interface to capture those queries.
精彩评论