[nzlug] quoting perl strings
Glenn Enright
glenn.enright at gmail.com
Mon Oct 1 11:25:40 NZST 2007
On 01/10/2007, Simon Green <simon at simongreen.net> wrote:
> On 01/10/2007, Glenn Enright <glenn.enright at gmail.com> wrote:
> > On 01/10/2007, Simon Green <simon at simongreen.net> wrote:
> > > use DBI (and the DBD for your database), and you won't need to worry
> > > about quoting at all. A way over simplified example is
> > > $dbh->do("INSERT INTO example (col1, col2) VALUES (?, ?)", undef,
> > > $string1, $string2);
> >
> > So this would work for te cas where $string1 has double or single quotes?
>
> Yes.
>
Sweet, that makes it a whole bunch easier. I read about interpolation
somewhere but didint realise the fringe benifits :).
@ Robin, thanks for th tips, I'm already using prepare statements, and
I was using a regex to substitite the chars with an escaped char.
Sucks to maintain as every time a special char turns up I would have
to manually add it in.
Cheers for the help guys
--
See my blog at
http://snap-happy3216.blogspot.com
More information about the NZLUG
mailing list