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

Re: DBI search for forward slash

by hippo (Bishop)
on Nov 08, 2020 at 11:43 UTC ( [id://11123502]=note: print w/replies, xml ) Need Help??


in reply to DBI search for forward slash

How can I perform exact search strings with with slashes?

Like this:

use strict; use warnings; use DBI; use Test::More tests => 2; my $dbh = DBI->connect('dbi:SQLite:dbname=/tmp/testdb','',''); $dbh->do ('CREATE TABLE foo (bar VARCHAR(255) NOT NULL)'); my $sth = $dbh->prepare ('INSERT INTO foo values (?)'); $sth->execute ('This has no slashes'); $sth->execute ('/a/b/c'); my $want = '/a/b/c'; $sth = $dbh->prepare ('SELECT * FROM foo WHERE bar = ?'); my $res = $sth->execute ($want); ok $res, 'True result'; my ($str) = $sth->fetchrow_array; is $str, $want, 'Strings match';

Essential reading:


🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11123502]
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: (3)
As of 2024-04-25 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found