This topic is locked
[SOLVED]

 db query customization

1/17/2015 10:45:50 AM
PHPRunner General questions
S
sawanr author

Hi,
May be someone can help me with below:
I need to run below query to save additional user information in mysql for audit purpose. below query needs to be executed before any mysql_query().
$set1 = "SET @app_username = '".$_SESSION['UserID']."'";

$set2 = "SET @app_user_ip = '".$_SERVER['REMOTE_ADDR']."'";

mysql_query($set1,$conn); mysql_query($set2,$conn);
my best guess is to customize dbconnection.my.mysql.php under db_query() function, but that didn't seem to do the job.
thanks,

sawan

Sergey Kornilov admin 1/17/2015

Why don't you use a built-in CustomQuery function:

CustomQuery("insert into myaudittable (username,ip) values('...','...')");
S
sawanr author 1/18/2015



Why don't you use a built-in CustomQuery function:

CustomQuery("insert into myaudittable (username,ip) values('...','...')");



Thanks for your response.
I know I could use CustomQuery(), however, I want something where I could execute this query exact before every page add/edit/delete event, my project has about 40+ tables, so I would looking to find an easy way to do it instead of going into each page add/edit/delete event.

Sergey Kornilov admin 1/19/2015

Use built-in Audit Log funcionality?

Use AfterAppInit event for this purpose?

S
sawanr author 1/21/2015



Use built-in Audit Log funcionality?

Use AfterAppInit event for this purpose?


I never noticed AfterAppInit until now. this is perfect. worked like a charm!
I don't use built-in audit log because this project requires saving audit log in a special format that is easy to read and restore data back from log if needed.