escaping % AND \%
- From: moseley@xxxxxxxx (Bill Moseley)
- Date: Fri, 29 Jun 2007 07:31:12 -0700
I have a very simple search using ILIKE and binding like:
$sth->execute( '%' . $user_input . '%' );
The docs show this for escaping SQL pattern chars:
$esc = $dbh->get_info( 14 ); # SQL_SEARCH_PATTERN_ESCAPE
$search_pattern =~ s/([_%])/$esc$1/g;
But if $search_pattern is '\%' then you end up with '\\%'.
I suppose the easy thing is to s/$esc//g first. What's the approach
if the $esc is a valid character for the column data?
--
Bill Moseley
moseley@xxxxxxxx
.
- Follow-Ups:
- Re: escaping % AND \%
- From: Raf
- Re: escaping % AND \%
- Prev by Date: DBD::mysql connect dying with "Can't initialize character set latin1"
- Next by Date: Re: escaping % AND \%
- Previous by thread: DBD::mysql connect dying with "Can't initialize character set latin1"
- Next by thread: Re: escaping % AND \%
- Index(es):