On Sun, Mar 05, 2006 at 01:27:55PM -0500, Sam Tregar wrote:
> Hey guys.  This one has bitten me one too many times.  Given this
> table:
> 
>   CREATE TABLE foo (
>      foo_id INT,
>      bar    VARCHAR(255)
>   );
> 
> This prepare() and execute() produces a very helpful warning:
> 
>    my $sth = $dbh->prepare("INSERT INTO foo VALUES (?,?)");
>    $sth->execute(1, "test 1", "too many");'
> 
> Specifically:
> 
>    DBD::mysql::st execute failed: called with 3 bind variables when 2 are
>    needed
> 
> However, this do() call doesn't:
> 
>    $dbh->do("INSERT INTO foo VALUES (?,?)", undef,
>             1, "test 1", "too many");
> 
> Do you agree this is a bug?

Yes.

> Any ideas about where I should look first to fix it (DBI or DBD::mysql, for 
> example)?

DBD::mysql. The DBI's do() is just:

    sub do {
        my($dbh, $statement, $attr, @params) = @_;
        my $sth = $dbh->prepare($statement, $attr) or return undef;
        $sth->execute(@params) or return undef;
        my $rows = $sth->rows;
        ($rows == 0) ? "0E0" : $rows;
    }   

Tim.

> Thanks,
> -sam
> 
> PS: DBI v1.46, DBD::mysql v2.90004.  My appologies if this is fixed
> already in a later version.
> 
> 

Reply via email to