Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9F91C63235B for ; Mon, 5 Oct 2009 19:05:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 65280-05 for ; Mon, 5 Oct 2009 22:05:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.bandbreiter.net (h1057542.serverkompetenz.net [85.214.72.161]) by mail.postgresql.org (Postfix) with ESMTP id BC67162E9C1 for ; Mon, 5 Oct 2009 19:05:09 -0300 (ADT) Received: from [192.168.34.189] (95-88-199-142-dynip.superkabel.de [95.88.199.142]) by www.bandbreiter.net (Postfix) with ESMTPA id C9FD333944F for ; Tue, 6 Oct 2009 00:05:07 +0200 (CEST) Message-ID: <4ACA6D38.4010005@gmx.de> Date: Tue, 06 Oct 2009 00:03:36 +0200 From: Marco Dieckhoff User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: checking select query syntax and semantics via php without executing References: <4ACA6668.2000701@gmx.de> <20091005180139.25cc9511.wmoran@potentialtech.com> In-Reply-To: <20091005180139.25cc9511.wmoran@potentialtech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.74 tagged_above=-10 required=5 tests=BAYES_20=-0.74 X-Spam-Level: X-Archive-Number: 200910/4 X-Sequence-Number: 4083 Bill Moran schrieb: > In response to Marco Dieckhoff : >> Hi there! >> >> Is it possible in PHP to give a sql (select) query to Postgres via pg_* >> so that it is NOT executed but merely checked for syntax including >> correct, existing field and table names, and data types? > Off the top of my head, you could prefix the query with EXPLAIN, which > will cause it to be planned (thus checking syntax) and return an > execution plan, but not actually run the query. Works as a charm, thanks to both of you. Must be one of the quickest "case solved, thread closed" I have ever seen :)