Re: [GENERAL] standard_conforming_strings and pg_escape_string()

2009-04-24 Thread Conrad Lender
On 24/04/09 14:49, Daniel Verite wrote: > It works for me: > > $ php -e > echo phpversion(), "\n"; > $c=pg_connect("dbname=mail user=daniel host=/tmp port=5000"); > pg_query("SET standard_conforming_strings=off"); > echo pg_escape_string('toto\titi'), "\n"; > pg_query("SET standard_conforming_str

Re: [GENERAL] standard_conforming_strings and pg_escape_string()

2009-04-24 Thread Tom Lane
Conrad Lender writes: > On 24/04/09 00:56, Tom Lane wrote: >> The above cannot possibly work. pg_escape_string is generating what it >> supposes to be a normal string literal, and then you are sticking an 'E' >> on the front which changes the escaping rules. It is not the function's >> fault tha

Re: [GENERAL] standard_conforming_strings and pg_escape_string()

2009-04-24 Thread Daniel Verite
Conrad Lender wrote: I would like our database abstraction to be able to handle both settings for standard_conforming_strings transparently, i.e. perform the escaping according to the current DB server settings. Since pg_escape_string() is aware of the current database connection, I

Re: [GENERAL] standard_conforming_strings and pg_escape_string()

2009-04-23 Thread Joshua D. Drake
On Thu, 2009-04-23 at 21:33 +0200, Conrad Lender wrote: > Hi. > I would like our database abstraction to be able to handle both settings > for standard_conforming_strings transparently, i.e. perform the escaping > according to the current DB server settings. Since pg_escape_string() is > aware of

Re: [GENERAL] standard_conforming_strings and pg_escape_string()

2009-04-23 Thread Conrad Lender
Tom, thanks for your reply. On 24/04/09 00:56, Tom Lane wrote: >> if ($escWildcards) { >> $str = strtr($str, array("%" => '\%', "_" => '\_')); >> } >> return "E'" . pg_escape_string($str) . "'"; > > The above cannot possibly work. pg_escape_string is generating what it > supposes to b

Re: [GENERAL] standard_conforming_strings and pg_escape_string()

2009-04-23 Thread Tom Lane
Conrad Lender writes: > I'm using PostgreSQL 8.3 with PHP's "pgsql" module (libpq 8.3.7). When > the server's standard_conforming_strings setting is off (this is > currently still the default, I believe), I use something like this to > escape strings: > if ($escWildcards) { > $str = strtr($