Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: DBI Question

by jreades (Friar)
on Jan 17, 2001 at 03:08 UTC ( [id://52405]=note: print w/replies, xml ) Need Help??


in reply to DBI Question

You can do this:

$sth = $dbh->prepare("SELECT name FROM people WHERE name LIKE ?"); $sth->execute('%foo%');

Just, remember, as I said in chatterbox, to escape the wildcard character '%'.

Replies are listed 'Best First'.
Re: Re: DBI Question
by dsb (Chaplain) on Jan 17, 2001 at 03:13 UTC
    The value I will bind to the placeholder is SCALAR variable. Can this still be done like:
    $sth = $dbh->prepare("SELECT name FROM people WHERE name LIKE ?"); $sth->execute( "$foo\%" );

      You'll have to test it for yourself, but I don't see why not...

      An easier way, if you know that you're always doing wildcard searches, might be:

      $sth->execute('%' . $foo . '%');
        That helps alot...Thanks!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://52405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 19:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found