[Dbix-class] Search like + autocomplete

Ashley apv at sedition.com
Fri Feb 1 19:44:28 GMT 2008


I asked a long time back about engine specific escape sequences to  
sanitize LIKE queries. I got pointed to a neat snippet from the DBI  
docs but mostly heard "don't use search (or search_like).

 >>>>>    $esc = $dbh->get_info( 14 );  # SQL_SEARCH_PATTERN_ESCAPE
 >>>>>    $search_pattern =~ s/([_%])/$esc$1/g;

I think the second should probably be amended to:
    $search_pattern =~ s/([_%]|$esc)/$esc$1/g;

Then I can
    $search_pattern . '%'


I'm doing something with some Ajax auto-complete. So I have no choice  
but to use search like, right? Any other strategies for this that I'm  
missing?


Thanks!
-Ashley



More information about the DBIx-Class mailing list