Re: escape single quote in INSERT command

From: wsheldah(at)lexmark(dot)com
To: dave_h4(at)yahoo(dot)com (Hunter)
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: escape single quote in INSERT command
Date: 2002-11-27 14:24:26
Message-ID: OF7B1A45AB.5ADD074E-ON85256C7E.004ECDBC@lexmark.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


If you're using DBD::Pg, just use ? placeholders without any quotes and let
it do the escaping for you:

$sth = $dbh->prepare("insert into customer (name) values (?)");
$sth->execute($name);

Makes the code a little more portable too. Hope this helps,

Wes

dave_h4(at)yahoo(dot)com (Hunter)@postgresql.org on 11/22/2002 08:00:31 AM

Sent by: pgsql-general-owner(at)postgresql(dot)org

To: pgsql-general(at)postgresql(dot)org
cc:
Subject: [GENERAL] escape single quote in INSERT command

Hi Group -

I have a perl application for a registration form. I'd like to put
escape characters in my insert command to accommodate for '
(i.e. O'Brien, O'Malley, etc). I've tired double quotes, single
quotes, back tick, forward ticks, curly bracket, round brackets - no
success.

Thanks, dave

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Browse pgsql-general by date

  From Date Subject
Next Message Ken Guest 2002-11-27 14:29:16 rename
Previous Message Jeff Sacksteder 2002-11-27 13:57:46 Re: null date comparison(DISREGARD!)