[Dbix-class] Correct (and secure) searching using -like?

Octavian Rasnita orasnita at gmail.com
Mon Oct 8 07:49:21 GMT 2012


Hi,

I've seen examples of searching in a database using the LIKE operator like:

$rs = $rs->search( {
    name => { -like => "%$name%" },
} );

It doesn't look to be very secure to quote the variable $name this way.
Or maybe the special chars in the whole composed string "%$name%" are then escaped if -like key is used?
Or is there a better alternative?

Thanks.

--Octavian




More information about the DBIx-Class mailing list