bradcathey has asked for the wisdom of the Perl Monks concerning the following question:
Fellow Monasterians,
I'm completely puzzled by behavior I haven't experienced when using placeholders and bind values. It's a though I need to quote values or something. What am I missing after years of successful use?
my $stmt = q/SELECT * FROM users WHERE username= ? AND password = ?/; my @bind = ( $username, $password ); # doesn't work my @bind = ( 'wilma', 'foobar' ); # works my $acct = $dbh->selectrow_hashref($stmt, undef, @bind );
Update: I'm updating this because I don't want anyone who might be new to DBI to stumble across this node and be misled. Turns out, it had something, not sure what, with a dicey connection to our web server. Sounds crazy, but for an hour before a crash, the posted code didn't work with scalars, only hard-coded values. The server went down, and after the reboot, the code worked has it has for years. Sorry to waste previous PM bandwidth on an bizarre anomaly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Is there a need to escape bind values in DBI
by moritz (Cardinal) on Jan 15, 2008 at 20:32 UTC | |
|
Re: Is there a need to escape bind values in DBI
by runrig (Abbot) on Jan 15, 2008 at 19:39 UTC | |
|
Re: Is there a need to escape bind values in DBI
by perrin (Chancellor) on Jan 15, 2008 at 20:13 UTC | |
by bradcathey (Prior) on Jan 15, 2008 at 20:26 UTC |