Name

sqlSelectAllHashref — returns a reference to a hash of hashes of rows returned from a SQL statement

Synopsis

my $hashref = $slashdb->sqlSelectAllHashref($id);
my $hashref = $slashdb->sqlSelectAllHashref($id, $select);
my $hashref = $slashdb->sqlSelectAllHashref($id, $select, $from);
my $hashref = $slashdb->sqlSelectAllHashref($id, $select, $from, $where);
my $hashref = $slashdb->sqlSelectAllHashref($id, $select, $from, $where, $other);

sqlSelectAllHashref builds and executes a SQL statement, returning a reference to a hash containing each row of the results as a separate hash. The leading $id parameter is the name of a field used as a key for each row hash in the parent hash reference. Otherwise, it uses the same parameters and handles errors in the same fashion as sqlSelect. This function trades memory for speed, returning all results and closing the statement handle as soon as possible. Note that the only order that can be imposed on the results can be done with the parent hash keys.

Example

my $hash_ref = $slashdb->sqlSelectAllHashref('uid', 'nickname, uid, realemail', 
'users', "karma > $karma");
foreach my $uid (keys %$hash_ref) {
    print "User: $uid, nickname: $uid->{nickname}, email: $uid->{realemail}\n";
}

Get Running Weblogs with Slash now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.