G'day Bod,
I tried to reproduce your problem but couldn't.
I created a test database:
$ sqlite3 bod SQLite version 3.34.0 2020-12-01 16:14:00 Enter ".help" for usage hints. sqlite> create table Person (idPerson, email, altEmail); sqlite> insert into Person values (1, 'you@example.com', ''); sqlite> insert into Person values (2, '', 'me@example.com'); sqlite> insert into Person values (3, 'me@example.com', ''); sqlite> select * from Person; 1|you@example.com| 2||me@example.com 3|me@example.com| sqlite>
Then a test script:
#!/usr/bin/env perl use strict; use warnings; use DBI; my $dbh = DBI->connect("dbi:SQLite:dbname=bod"); print "Contents of Person:\n"; eval { print join('|', @$_), "\n" for $dbh->selectall_array('select * fro +m Person'); 1; } or do { print $dbh->errstr, "\n"; }; print "Head-scratching code:\n"; eval { my %data = (email => 'me@example.com'); my $crid = $dbh->selectrow_array("SELECT idPerson FROM Person WHER +E email = ? OR altEmail = ?", undef, $data{'email' }, $data{'email'}); print "$crid\n"; 1; } or do { print $dbh->errstr, "\n"; };
Output:
Contents of Person: 1|you@example.com| 2||me@example.com 3|me@example.com| Head-scratching code: 2
As you can see, I had to make some guesses; however, I used a verbatim copy of your selectrow_array(). It correctly found the idPerson (i.e. 2) using your parameters.
Instead of presenting us with bits of isolated code, please provide an SSCCE that reproduces your problem and is written in such a way that we can run it and help you towards a solution.
What you could also do is create a temporary directory and, in there, create the test database exactly as I have and run exactly the same test script I presented; then compare the output.
— Ken
In reply to Re: Recalcitrant placeholders
by kcott
in thread Recalcitrant placeholders
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |