Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

gav (2710)

  (email not shown publicly)
AOL IM: flufflegavin (Add Buddy, Send Message)

Hacker in NYC.

Journal of gav (2710)

Thursday September 19, 2002
10:29 AM

dbi debugging aid

[ #7835 ]
Want to know what sql you're throwing at the database but you're binding variables. This should do the trick:

use Text::Wrap;
my $temp = $sql;
$temp =~ s/\?/$dbh->quote($_)/e for @data;
print $cgi->pre(wrap('','',$temp));

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • DBI->trace(2) is your friend.
  • What happens if one of your values contains a question mark? I had a similar bug in the DBI-ish class I was writing in PHP a few weeks back.
    • Doh. I didn't think of that :(

      This works for that case:

      my $i = 0;
      $temp =~ s/\?/$dbh->quote($data[$i++])/ge;