Mysql Statements just prior to Commitment

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
primitive_man
AppGini Super Hero
AppGini Super Hero
Posts: 54
Joined: 2014-03-09 20:20

Mysql Statements just prior to Commitment

Post by primitive_man » 2014-03-09 20:27

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

benzoD
Veteran Member
Posts: 69
Joined: 2013-01-31 21:16

Re: Mysql Statements just prior to Commitment

Post by benzoD » 2014-03-10 13:10

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.

primitive_man
AppGini Super Hero
AppGini Super Hero
Posts: 54
Joined: 2014-03-09 20:20

Re: Mysql Statements just prior to Commitment

Post by primitive_man » 2014-03-11 10:46

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

primitive_man
AppGini Super Hero
AppGini Super Hero
Posts: 54
Joined: 2014-03-09 20:20

Re: Mysql Statements just prior to Commitment

Post by primitive_man » 2014-03-14 13:41

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?

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Mysql Statements just prior to Commitment

Post by a.gneady » 2014-03-15 16:57

You can declare a global variable, for example $old_value by adding this line at the beginning of each function:

Code: Select all

global $old_value;
You can then store the old value in it in the before_update hook, then read it in the after_update hook.
:idea: 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.

Post Reply