Page 1 of 1
Mysql Statements just prior to Commitment
Posted: 2014-03-09 20:27
by primitive_man
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
Re: Mysql Statements just prior to Commitment
Posted: 2014-03-10 13:10
by benzoD
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.
Re: Mysql Statements just prior to Commitment
Posted: 2014-03-11 10:46
by primitive_man
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
Re: Mysql Statements just prior to Commitment
Posted: 2014-03-14 13:41
by primitive_man
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?
Re: Mysql Statements just prior to Commitment
Posted: 2014-03-15 16:57
by a.gneady
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.