Mailing List Archive

$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 [ In reply to ]
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
-------------------------------------------------------------