X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A22F0D1CA95 for ; Mon, 22 Sep 2003 14:43:12 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 40216-10 for ; Mon, 22 Sep 2003 11:42:45 -0300 (ADT) Received: from hosting.commandprompt.com (218.commandprompt.com [207.173.200.218]) by svr1.postgresql.org (Postfix) with ESMTP id 8E5D7D1CA8C for ; Mon, 22 Sep 2003 11:42:23 -0300 (ADT) Received: from commandprompt.com (dsl093-077-251.sea2.dsl.speakeasy.net [66.93.77.251]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id h8MEg5c17141; Mon, 22 Sep 2003 07:42:06 -0700 Message-ID: <3F6F0A3C.1080205@commandprompt.com> Date: Mon, 22 Sep 2003 07:42:04 -0700 From: Robby Russell Organization: Command Prompt, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: sector119@mail.ru, pgsql-php@postgresql.org Subject: Re: how am I able to log all sql queries? References: <20030922050406.GA20466@city.gov.te.ua> In-Reply-To: <20030922050406.GA20466@city.gov.te.ua> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/75 X-Sequence-Number: 2352 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