On Tue, Sep 14, 2004 at 12:34:09AM +0200, Jenda Krynicky wrote:
> From: Tim Bunce <[EMAIL PROTECTED]>
> >
> > Use bind_param() or bind_param_inout() for all the params
> > and then call execute() with no arguments.
> >
> > Tim.
>
> I wonder ... how about adding a method bind_params() like this:
>
> sub bind_params {
> my $sth = shift;
> my $pos = (ref($_[0]) ? 1 : shift);
> for my $param (@{$_[0]}) {
> $sth->bind_param($pos++, $param);
> }
> }
No need. See below.
> So that this could be shortened to
>
> $sth->bind_params([EMAIL PROTECTED]); # default position is 1
> $sth->bind_param_inout($#execute_args+1,\$new_id,38);
Without adding any new methods it can be shortened to
$sth->bind_param($_, $execute_args[$_]) for ([EMAIL PROTECTED]);
$sth->bind_param_inout($#execute_args+1, \$new_id, 38);
I'll add that to the docs.
Tim.
p.s. I'd use "scalar @execute_args" or "[EMAIL PROTECTED]" instead of
"$#execute_args+1".