pg_escape with copy

pg_escape with copy

am 26.02.2008 03:46:17 von blackwater dev

------=_Part_18959_22288760.1203993977407
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I have data that I'm running through pg_escape_sting in php and then adding
to stdin for a copy command. The problem is "O'reilly" is being changed to
"O''Reilly" in the string and then in the db. I saw with the copy command I
can specify the escape but it isn't working for me. Should this command fix
this double 'single' quote issue when I put it in the db? And what is the
proper syntax?

COPY mytable FROM stdin with escape



Thanks!

------=_Part_18959_22288760.1203993977407--

RE: pg_escape with copy

am 26.02.2008 15:08:07 von Bastien Koert

--_fc8f0db5-963e-419b-80fa-28205c5b94bb_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


try using htmlentitites first to conver the ' to ' instead
=20
bastien
> Date: Mon, 25 Feb 2008 21:46:17 -0500> From: blackwaterdev@gmail.com> To:=
php-db@lists.php.net> Subject: [PHP-DB] pg_escape with copy> > I have data=
that I'm running through pg_escape_sting in php and then adding> to stdin =
for a copy command. The problem is "O'reilly" is being changed to> "O''Reil=
ly" in the string and then in the db. I saw with the copy command I> can sp=
ecify the escape but it isn't working for me. Should this command fix> this=
double 'single' quote issue when I put it in the db? And what is the> prop=
er syntax?> > COPY mytable FROM stdin with escape> > > > Thanks!
____________________________________________________________ _____


--_fc8f0db5-963e-419b-80fa-28205c5b94bb_--

Re: pg_escape with copy

am 27.02.2008 01:20:16 von dmagick

blackwater dev wrote:
> I have data that I'm running through pg_escape_sting in php and then adding
> to stdin for a copy command. The problem is "O'reilly" is being changed to
> "O''Reilly" in the string and then in the db. I saw with the copy command I
> can specify the escape but it isn't working for me. Should this command fix
> this double 'single' quote issue when I put it in the db? And what is the
> proper syntax?

AFAIK "copy" takes the csv file and imports it (and handles quotes etc
itself).

So just create your file:

First Name, Last Name
Tim, O'Reilly

and when you "copy" that in (without the header line), it'll "just work".

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php