I have created a PHP script and I am lacking to extract the primary key, I have given flow below, pl

Posted by Parth on Stack Overflow See other posts from Stack Overflow or by Parth
Published on 2010-04-09T06:08:08Z Indexed on 2010/04/09 6:13 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

I am using MySQL DB, working for Joomla, My requirement is tracking the activity like insert/update/delete on any table and store it in another audit table using triggers, i.e. I am doing Auditing. DB's table structure: Few tables dont have any PK nor auto increment key

Flow of my script is :

  1. I fetch out all table from DB.
  2. I check whether the table have any trigger or not.
  3. If yes then it moves to check nfor next table and so on.
  4. If it does'nt find any trigger then it creates the triggers for the table, such that, -it first checks if the table has any primary key or not(for inserting in Tracking audit table for every change made)
    • if it has the primary key then it uses it further in creation of trigger.
    • if it doesnt find any PK then it proceeds further in creating the trigger without inserting any id in audit table

Now here, My problem is I need the PK every time so that I can record the id of any particular table in which the insert/update/delete is performed, so that further i can use this audit track table to replicate in production DB.. Now as I haave mentioned earlier that I am not available with PK/auto-incremented in some table, then what should I do get the particular id in which change is done?

please guide me...GEEKS!!!

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql