in reply to Re: DBI prepare() vs do() usage
in thread DBI prepare() vs do() usage

Thanks, edan!

I didn't know I could use a placeholder with do(). I'll definitely use do() for a one-off execution now that I now it's possible to use a placeholder.

Btw, why do you need the 'undef' there? Is it compulsory?

Replies are listed 'Best First'.
3Re: DBI prepare() vs do() usage
by jeffa (Bishop) on Dec 21, 2003 at 14:54 UTC
    RTFM! At the top:
    $rv = $dbh->do($statement); $rv = $dbh->do($statement, \%attr); $rv = $dbh->do($statement, \%attr, @bind_values);
    Since @bind_values is the 3rd arg and you aren't specifying \%attr, you use either undef or {} in it's place:
    $rv = $dbh->do($statement, undef, @bind_values); $rv = $dbh->do($statement, {}, @bind_values);
    So, then what is \%attr used for? Well, search for that string in the docs and you will be lead to:
       Notation and Conventions
    
       The following conventions are used in this document:
          $dbh    Database handle object
          $sth    Statement handle object
    
          ... yadda yadda ...
    
          undef   NULL values are represented by undefined values in Perl
          \%attr  Reference to a hash of attribute values passed to methods
    
    Do a little more research first, then ask us. :)

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)