What is the best way to construct a LIKE search with DBI? I know that I should always use $dbi->quote or a placeholder to keep the search string from messing up my SQL statement (the search string will be entered by a user on a webpage), and I have read that using a placeholder in this case can cause performance problems. However, using $dbi->quote on a search string like "%foo%" (where "foo" is the string entered by the user on the webpage and %'s are added by the program) will quote out the %'s. I also can't just put %'s on the outsides of the quoted string, because the quote function adds in quotes, so that would give me "%'foo'%". In the past, I've used $dbi->quote on the search string without the %'s, then used a regex to add a % after the first ' and before the last ' in the string. Certainly there's a better way!
Thanks,
Curtis H.
In reply to DBI, quoting, and LIKE searches by Mr_Person
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |