pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
how am I able to log all sql queries?
2+ messages / 2 participants
[nested] [flat]

* how am I able to log all sql queries?
@ 2003-09-22 05:04 sector119@mail.ru
  2003-09-22 14:42 ` Re: how am I able to log all sql queries? Robby Russell <rrussell@commandprompt.com>
  0 siblings, 1 reply; 2+ messages in thread

From: sector119@mail.ru @ 2003-09-22 05:04 UTC (permalink / raw)
  To: pgsql-php

hi

I want to log all queries which has been executed by my program!

like:
*user_ip* who run program, and *queries* which has been executed durin
time that he use this program (my site)

-- 
WBR, sector119



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: how am I able to log all sql queries?
  2003-09-22 05:04 how am I able to log all sql queries? sector119@mail.ru
@ 2003-09-22 14:42 ` Robby Russell <rrussell@commandprompt.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Robby Russell @ 2003-09-22 14:42 UTC (permalink / raw)
  To: sector119@mail.ru; pgsql-php

sector119@mail.ru wrote:
> hi
> 
> I want to log all queries which has been executed by my program!
> 
> like:
> *user_ip* who run program, and *queries* which has been executed durin
> time that he use this program (my site)
> 

PostgreSQL can log it for you, but if you want to do it on a client 
basis, I'd create a log table in your db and add a function to your 
program that for each time you execute a query, you log the ip and the 
sql query to the database table. If you're using pg_query or something 
you could create a custom function like so: (don't mind the horrible 
php, but you might get the idea I'm trying to show.)


function pg_log_query($ip, $sql) {
   # query to insert the sql to the database
   pg_query("INSERT INTO logging (ip, sql) VALUES ('$ip', '$sql');

   # call the normal pg_query
   pg_query($sql);
}


Hope that helps


-- 
Robby Russell,  |  Sr. Administrator / Lead Programmer
Command Prompt, Inc.   |  http://www.commandprompt.com
rrussell@commandprompt.com | Telephone: (503) 222.2783




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-09-22 14:42 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-22 05:04 how am I able to log all sql queries? sector119@mail.ru
2003-09-22 14:42 ` Robby Russell <rrussell@commandprompt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox