tags:

views:

9

answers:

1

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 = "INSERT 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.

A: 

You can't get the statements, only their results / alterations. Consider using a database abstraction- or decorator-interface to capture those queries.

Wrikken
That's Unfortunate. Thanks for the answer, despite the fact that I don't like it.
Troy Knapp