SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.
    Barbara

  2. #2
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by barbara1712 View Post
    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?
    Barbara

  3. #3
    Community Advisor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,389
    Mentioned
    45 Post(s)
    Tagged
    12 Thread(s)
    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?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •