SPUG: Turning off auto-quoting during DBI Binding.

Stephen Blum zstephenblum at hotmail.com
Tue Apr 8 10:59:44 PDT 2008

Hey SPUG Team,
Thank you for the quick responses and all the different ways a programmer can solve this type of problem.  The manual substitution method has done the trick!
Thank you again,

> Date: Tue, 8 Apr 2008 07:32:18 -0700> Subject: Re: SPUG: Turning off auto-quoting during DBI Binding.> From: sthoenna at efn.org> To: zstephenblum at hotmail.com> CC: spug-list at pm.org> > On Mon, Apr 07, 2008 at 08:30:35PM -0700, Stephen Blum wrote:> > How does one turn off the annoying and sometimes unneeded auto-quoting> that occurs during DBI Bindings? I have searched the net for a while> now and have found little on the subject.> >> > example:> >> > $sql = q(thrrr_id in (?));> > $sth = $dbh->prepare($sql);> > $sth->execute( q(1,2,3,4,5) );> >> > DBI executes this: thrrr_id in ('1,2,3,4,5')> > But I want to execute this: thrrr_id in (1,2,3,4,5)> >> > DBI adds quotes and I don't want them. If there is no way around this I> can forgo the performance/convenience of bindings.> > There's no way around it. Either just interpolate into the query:> > $ids = "1,2,3,4,5";> $sql = qq(thrrr_id in ($ids));> $sth = $dbh->prepare($sql);> $sth->execute();> > or use an array and provide the appropriate number of ? instead:> > @ids = (1,2,3,4,5);> $sql = 'thrrr_id in ('.join(',',('?') x @ids).')';> $sth = $dbh->prepare($sql);> $sth->execute(@ids);> > > 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/spug-list/attachments/20080408/2946e325/attachment.html 

More information about the spug-list mailing list