Hi,
I need to be able to access the Mysql statement (Update/Insert/Delete only) just before it committed - ie. Just prior to the '$result = mysql_query($query);' kind of statement.
Anyone know where I'd find this in the code?
Thanks, Helen
Mysql Statements just prior to Commitment
-
- AppGini Super Hero
- Posts: 54
- Joined: 2014-03-09 20:20
Re: Mysql Statements just prior to Commitment
In AppGini this is accessed through the tablename_before_insert, tablename_before_update and tablename_before_delete hooks in the tablename.php file in the hooks directory.
Here is a link to the relevant section of the documentation that describes hooks and how to use them.
Here is a link to the relevant section of the documentation that describes hooks and how to use them.
-
- AppGini Super Hero
- Posts: 54
- Joined: 2014-03-09 20:20
Re: Mysql Statements just prior to Commitment
Thank you for this information but it doesn't fit my requirements.
Problem: I need to see the sql statement that loads the existing record on-load (Detail View), I then need to see the sql statement just prior to UPDATE/INSERT/DELETE
Reason: I have a php script that compares both sql statements, notes the differences and then creates an audit log of changes
Problem: I need to see the sql statement that loads the existing record on-load (Detail View), I then need to see the sql statement just prior to UPDATE/INSERT/DELETE
Reason: I have a php script that compares both sql statements, notes the differences and then creates an audit log of changes
-
- AppGini Super Hero
- Posts: 54
- Joined: 2014-03-09 20:20
Re: Mysql Statements just prior to Commitment
and... if I do a mysql_fetch_assoc BEFORE an update and a mysql_fetch_assoc AFTER the update -> both arrays are identical.
I'm certain that the AFTER update mysql_fetch_assoc should reflect a change - ie, an Updated field value.
That's what hooks names: '_before_update' & '_after_update' imply, do they not?
I'm certain that the AFTER update mysql_fetch_assoc should reflect a change - ie, an Updated field value.
That's what hooks names: '_before_update' & '_after_update' imply, do they not?
Re: Mysql Statements just prior to Commitment
You can declare a global variable, for example $old_value by adding this line at the beginning of each function:
You can then store the old value in it in the before_update hook, then read it in the after_update hook.
Code: Select all
global $old_value;
AppGini plugins to add more power to your apps:
- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.