Name

sqlSelectColArrayref — returns a reference to an array of the first column from each row of the results returned from a SQL statement

Synopsis

my $arr = $slashdb->sqlSelectColArrayref($select);
my $arr = $slashdb->sqlSelectColArrayref($select, $from);
my $arr = $slashdb->sqlSelectColArrayref($select, $from, $where);
my $arr = $slashdb->sqlSelectColArrayref($select, $from, $where, $other);

sqlSelectColArrayref constructs and executes a SQL statement, returning a reference to an array holding only the first column of each row of the results. It takes the same parameters as sqlSelect and handles errors in the same way. In practice, this is little used. Note that requesting multiple fields in the $select parameter will have little effect.

Example

my $col_ref = $slashdb->sqlSelectColArrayref('nickname', 'users', "uid < 100");
foreach my $usernick (@$col_ref) {
    print "User: $usernick\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.