From: Robby Russell <rrussell@commandprompt.com>
To: sector119@mail.ru
To: pgsql-php@postgresql.org
Subject: Re: how am I able to log all sql queries?
Date: Mon, 22 Sep 2003 07:42:04 -0700
Message-ID: <3F6F0A3C.1080205@commandprompt.com> (raw)
In-Reply-To: <20030922050406.GA20466@city.gov.te.ua>
References: <20030922050406.GA20466@city.gov.te.ua>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: rrussell@commandprompt.com, sector119@mail.ru
Subject: Re: how am I able to log all sql queries?
In-Reply-To: <3F6F0A3C.1080205@commandprompt.com>
References: <20030922050406.GA20466@city.gov.te.ua> <3F6F0A3C.1080205@commandprompt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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