Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Get a hash object from a database with DBI for use with HTML::Template

by Cine (Friar)
on Aug 04, 2002 at 14:36 UTC ( #187489=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
        my $stmt = "SELECT * FROM $table WHERE $key_col = '$key_val'";
        my $sth = $dbhandle->prepare( $stmt );
  2. or download this
        my $stmt = "SELECT * FROM $table WHERE $key_col = ?";
        my $sth = $dbhandle->prepare( $stmt );
  3. or download this
        my $ref = $sth->fetchall_arrayref();
        return map { $_->[$name_col] => $_->[$val_col] } @$ref;
  4. or download this
        my $ref = $sth->fetchall_hashref([$name_col,$val_col]);
        return map {@$_} @$ref;
  5. or download this

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2015-11-27 14:10 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (729 votes), past polls