I have created a PHP script and I am lacking to extract the primary key, I have given flow below, please help me in how can i modify to get primary key
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 :
- I fetch out all table from DB.
- I check whether the table have any trigger or not.
- If yes then it moves to check for next table and so on.
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!!!