Insert Query

business

Member
Hi,

How can I find the insert query for debugging? I have enabled the display_sql from config.php, but it only shows select queries.

I am having a problem with one of the fields, the data calculated in it isn't being stored in the database, I have re-created every field, removed, and added the table again and done everything I can, but the field isn't being saved.

Is there any way I can see the insert queries to find out whats going on?

Thanks
 

eugenio

Administrator
Staff member
You don't see it because after the insert the user is redirected to the results grid.

You could add an after insert hook on the table you want to debug and put just an exit statement in the function:

$hooks['mytable']['insert']['after'] = 'dadabik_test';

function dadabik_test()
{
exit();
}
 

eugenio

Administrator
Staff member
You are welcome!
Please note that the queries won't be executed because the transaction is commited after the execution of the hook and you have an exit inside the hook.

Best,
 

business

Member
Got it, thanks.

Any way to restrict debugging to admin accounts, keeping users out of this?

Can hooks work for particular users?
 

eugenio

Administrator
Staff member
Hello,
hooks work for all users.

Debug statements, if enabled, work for all user. What you could you (you have to hack a little bit the code) is the following: in include/db_functions.php you will find several times this statement:

if ($debug_mode === 1){

you can change it with something like

if ($debug_mode === 1 && $GLOBALS['current_user_is_administrator'] === 1){

to limit it to the admin group (I haven't tested but it should work).

Best,
 
Top