Name

sqlSelectHashref — returns a reference to a hash for a single row of results from a SQL statement

Synopsis

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

sqlSelectHashref constructs and executes a SQL statement from its parameters. If the execution succeeds, it returns a reference to a hash for the first row of results. The hash keys are the field names, and the values are the field values. This function takes the same parameters as sqlSelect and handles errors in the same way.

Example

my $user = $selfdb->sqlSelectHashref('*', 'users', "uid=$uid");
print "Username: $user->{nickname}, homepage: $user->{homepage}\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.