Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: DBI and arrays

by Anonymous Monk
on Jan 17, 2012 at 12:34 UTC ( [id://948310]=note: print w/replies, xml ) Need Help??


in reply to Re^2: DBI and arrays
in thread DBI and arrays

my $sth = $dbh->prepare($SQLQueryString); my $array_ref = $dbh->selectall_arrayref( $SQLQueryString, { Slice => +{} }, @SQLvars );
First of all, you are preparing a statement handle, and then not using it (but using the database handle instead). Second, DBI does not expect named parametres (at least the way you're writing your placeholders), nor will that function accept an array of hashrefs. Instead, something like this would work:
$aref = $dbh->selectall_arrayref($sql, {stuff => 'here'}, 'TESTA1', 'T +ESTA2', 'TESTA3');

Replies are listed 'Best First'.
Re^4: DBI and arrays
by Anonymous Monk on Jan 17, 2012 at 12:46 UTC
    Just wanted to amend that, since you seem to be confused between the database handle functions and the statement handle functions, this would be the equivalent written using the sth functions:
    $sth = $dbh->prepare($sql); $sth->execute('TESTA1', 'TESTA2', 'TESTA3'); $aref = $sth->fetchall_arrayref({stuff => here});
    (the database handle functions offer the do() and select*() shortcuts for doing similar things, although they are not as efficient in some cases)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://948310]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-03-28 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found