Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:15551 php.internals:15552 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34350 invoked by uid 1010); 23 Mar 2005 03:48:22 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 34335 invoked from network); 23 Mar 2005 03:48:22 -0000 Received: from unknown (HELO gmail.com) (127.0.0.1) by localhost with SMTP; 23 Mar 2005 03:48:22 -0000 X-Host-Fingerprint: 64.233.184.199 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.199:5173] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity HEAD r(5268)) with SMTP id 5F/F0-04146-607E0424 for ; Tue, 22 Mar 2005 22:48:22 -0500 Received: by wproxy.gmail.com with SMTP id 37so66241wra for ; Tue, 22 Mar 2005 19:48:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=Gr5x0crbWkrUGuqCI8c45B3EhX3qwRksn3Xzr2YR96+mHa3JFkSEuNSavSHXXayEPtGGOoaZNhk1hnvRIaH8Ag3E+sxhtZCK76MhWLbVReskYE1YBHq0bt4lHasVu1qqZMW3XvqCUbx4aeGJ0zT99rr7zrLxPpdV1j4ChIcNU+g= Received: by 10.54.105.17 with SMTP id d17mr215683wrc; Tue, 22 Mar 2005 19:48:20 -0800 (PST) Received: by 10.54.44.57 with HTTP; Tue, 22 Mar 2005 19:47:50 -0800 (PST) Message-ID: <4e89b42605032219476a70a77d@mail.gmail.com> Date: Tue, 22 Mar 2005 22:47:50 -0500 Reply-To: Wez Furlong To: Christopher Kings-Lynne Cc: Dan Scott , php-dev In-Reply-To: <4240E38E.6060504@familyhealth.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit References: <423F84AD.9070809@familyhealth.com.au> <027201c52ed8$8b369170$1200000a@intra.emini.dk> <42402D82.8000305@familyhealth.com.au> <4240BFD5.9090605@familyhealth.com.au> <4e89b42605032219241edf4a16@mail.gmail.com> <4240E38E.6060504@familyhealth.com.au> Subject: Re: [PHP-DEV] pdo_pgsql From: kingwez@gmail.com (Wez Furlong) The problem with using $ in the query is that you'd need to \ escape them; remember that PHP uses $ to interpolate its own variables. IMO, adding $ as another way to name parameters is overkill, as we already have :named style. --Wez. On Wed, 23 Mar 2005 11:33:34 +0800, Christopher Kings-Lynne wrote: > > Depends on how you define "correctly" ;-) > > Chances are that it will raise an error. > > > > I'm not sure if this should really be considered a problem; that's a > > really obtuse SQL statement. As a non-pgsqler, I have a hard time > > figuring out where the variables are. > > Well, anything that's not perfect is a problem :) > > Dollar quoting is new in pgsql 8, it's sort of like 'heredocs'. > Basically it's to avoid having to escape ' in your function bodies, or > other strings, eg: > > CREATE FUNCTION test(int) RETURNS int AS > $tagname$ > SELECT 23 FROM table WHERE a > $1 AND b = 'hello' > $tagname$ LANGUAGE SQL; > > The 'tagname' is the dollar quote identifier, and everything from that > dollar quote opener to the end one will be considered a string literal. > Notice I do not have to escape the '' in the function body. > > It a perfectly reasonable thing, even encouraged thing to do. We'll > just have to upgrade the SQL parser to cope :P > > Prepared query parameters are indicated with $n syntax in PostgreSQL, > just to make things tricky :D > > ie: > > SELECT * FROM blah WHERE a = $1 AND b = $2; > > The $1 will get replaced with first param, $2 with second, etc. > > Maybe support should be added for this style of notation? It'd be > pretty easy I guess. > > > I welcome native postgres prepare/bind/execute support, and don't mind > > adjusting the pdo_sql_parser.re code to cater for rewriting ? or > > :named style substitutions into postgres style; it already includes > > some logic for rewriting ? to :named and vice-versa, so the > > modifications should be reasonably simple. > > Might be necessary. > > Chris >