Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 3735E476060; Fri, 24 Jan 2003 16:02:52 -0500 (EST) Received: from varsoon.wireboard.com (www.wireboard.com [216.151.155.101]) by postgresql.org (Postfix) with ESMTP id D5F9747612B; Fri, 24 Jan 2003 15:25:23 -0500 (EST) Received: from doug by varsoon.wireboard.com with local (Exim 3.35 #1) id 18cANk-00084r-00; Fri, 24 Jan 2003 15:24:56 -0500 To: Greg Stark Cc: gearond@cvc.net, "Nigel J. Andrews" , pgsql-general@postgresql.org, pgsql-interfaces@postgresql.org Subject: Re: More PHP DB abstraction layer stuff References: <2ZNYVFD2X72ONE0091WQPZXGJEC7WR.3e319071@cal-lab> <87r8b2nvwr.fsf@stark.dyndns.tv> From: Doug McNaught Date: 24 Jan 2003 15:24:56 -0500 In-Reply-To: Greg Stark's message of "24 Jan 2003 15:19:00 -0500" Message-ID: Lines: 27 User-Agent: Gnus/5.0806 (Gnus v5.8.6) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/1047 X-Sequence-Number: 36168 Greg Stark writes: > Doug McNaught writes: > > > $stmt = $dbh->prepare("select * from mytable where first_name = ?"); > > $ret_val = $sth->execute("Fred"); # might come from a web form instead > > @row = $sth->fetchrow_array(); > > > > The database driver is responsible for turning the '?' in the query > > into a properly-quoted and escaped value, or otherwise supplying it to > > the database. The '?' is a placeholder. > > Except that that's not what the driver does, at least not for databases that > are capable of doing better. It sends the placeholders to the database as they > are. (Or in a different syntax like :1 :2 :3 for Oracle for example.) Right, but currently for PG (this being a PG list :) it just does the quoting/escaping and builds the query itself. It's still safer than doing it by hand, as long as the database driver is trustworthy and knows the databases escaping conventions. I think there has been discussion about extending the protocol to allow Oracle-style prepared statement execution, but right now it isn't supported. Prepared queries only went in in 7.3, after all... -Doug