On Wed, Aug 05, 2009 at 08:19:42PM +0200, Denis BUCHER wrote:
> Hello,
> 
> Does someone knows if it's possible to specify an array when executing a
> prepared statement ?

The question seems confused...

> $sth->execute(%array_data)

%array_data isn't an array, it's a hash.
See http://perldoc.perl.org/perldata.html

> instead of :
> 
> $sth->execute($array_data["firstname"],array_data["lastname"])

Square brackets are used to access array elements, but in that case the
value in the square brackets must be an integer.

It looks like you're trying to use a hash. For that you'd use curly
braces, like this:

  $sth->execute( $hash_data{"firstname"}, $hash_data{"lastname"} );

Using 'hash slice' syntax (http://perldoc.perl.org/perldata.html#Slices)
you can shorten to:

  $sth->execute( @hash_data{"firstname", "lastname"} );

Tim.

Reply via email to