Re: standard_conforming_strings and pg_escape_string()

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: standard_conforming_strings and pg_escape_string()
Date: 2009-04-24 12:49:03
Message-ID: 31584b40-894d-4689-9663-ac2ed436cd89@mm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 had expected its behavior
to
> change accordingly:
>
> no std strings:
> x\y --> x\\y
> with std strings:
> x\y --> x\y

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_strings=on");
echo pg_escape_string('toto\titi'), "\n";
?>

Output:
5.2.0-8+etch13
toto\\titi
toto\titi

Best regards,

--
Daniel
PostgreSQL-powered mail user agent and storage:
http://www.manitou-mail.org

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message pavunkumar 2009-04-24 13:03:45 deleting function
Previous Message josep porres 2009-04-24 12:20:46 Re: update error