You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by indrek siitan <tf...@cafe.ee> on 2000/03/31 07:02:44 UTC
$dbh->quote and LIKE
Hi,
i know this is not a direct EmbPerl question, but most of you
fellow EmbPerl guys probably use DBI for database connectivity
and might have an idea, is there a "cleaner" solution to do
this thing:
--- 8< ---
$keyword=$dbh->quote($fdat{what});
$keyword=~s/^\'//;
$keyword=~s/\'$//;
$sth=$dbh->prepare("SELECT ... FROM TABLE WHERE field like '%$keyword%'");
--- 8< ---
Rgds,
Tfr
--==< tfr@cafe.ee >==< http://tfr.cafe.ee/ >==< +1-504-4467425 >==--
RE: $dbh->quote and LIKE
Posted by Gerald Richter <ri...@ecos.de>.
Hi,
>
> i know this is not a direct EmbPerl question, but most of you
> fellow EmbPerl guys probably use DBI for database connectivity
> and might have an idea, is there a "cleaner" solution to do
> this thing:
>
> --- 8< ---
>
> $keyword=$dbh->quote($fdat{what});
> $keyword=~s/^\'//;
> $keyword=~s/\'$//;
> $sth=$dbh->prepare("SELECT ... FROM TABLE WHERE field like '%$keyword%'");
>
> --- 8< ---
>
Use placeholders...
Gerald
-------------------------------------------------------------
Gerald Richter ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting
Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 925151
WWW: http://www.ecos.de Fax: +49 6133 925152
-------------------------------------------------------------