Accessing PHP Variable inside mysql triggers

Hi,

I want to create a trigger which will insert a data into my audit table before updating the ‘items’ table.

The columns in my table ‘items’ are (id, name, category, quantity, price_per_item)

What I want is when a one of the Admin users logs into the system and updates items table, then befor update data should get inserted into ‘audit’ table. The audit table has some additional columns like (updated_by, modified_on, IP address, browser).

These column values are available in my PHP Variables but how can I pass these into my triggers so that when update takes place, trigger will insert the data from ‘items’ table to ‘audit’ table.

Your help will be highly appriciated.

Thanks in advance.

Barbara.

No one?

Hi Barbara,

As far as I know, it’s not possible… I think that a trigger can only work with data that is already in the database, or part of the query that triggered the trigger, although you might want to ask over at the Database forum to be sure. Is there any reason that you can’t just update the audit table with a second query from PHP?