On Mon, 26 Nov 2001, Wilson, Doug wrote:
> > 
> > and I get this error:
> > Placeholder :0 invalid, placeholders must be >= 1 at 
> > /usr/lib/perl5/site_perl/5.005/i386-linux/DBD/Pg.pm line 118.
> 
> This would probably be a good place to use placeholders. I don't know
> how Postgres quotes or escapes things that need to be quoted or
> escaped, but placeholders or the $dbh->quote() method would do
> it correctly for you. And placeholders, IMO, would be easier.
> 

This is a bug in DBD::Pg.  

my $quoted = $db->quote('This is a test\\');
$db->do(qq{INSERT INTO tester VALUES($quoted ,NULL, 'bob:0')});

Will thow an error, and if you chage the bob:0 to bob:3 you will get
bob:NULL inserted into the databse.  I think that the  '\' at the end of
the first field is thowing the dbd_preparse off, and causing it think
that it is still in a comment until the next "'". WRT looking for place
holders, that is.

He should be able to get around this by using place holders (odly enough)
because the offending '\' will be added to the statement after it has been
parsed for placeholders.  So:

my $quoted = $db->quote('This is a test\\');
$db->do(qq{INSERT INTO tester VALUES(? ,NULL, 'bob:0')},{}, 'This is a 
test\\');

Will insert correctly

If I get a chance, I'll look into fixing this issue tonight or tommorw.


-Rudy

Reply via email to