On 3/16/09 Mon Mar 16, 2009 3:05 PM, "R. Hicks" <[email protected]>
scribbled:
> $template->param(
> RESULTS => $self->dbh->selectall_arrayref('
> SELECT age, day FROM table WHERE id = ?',
> { Slice => {} },
> $self->session->param('cell')->{'sid'} )
> );
>
>
> I saw that code and while I do database stuff I was wondering what that
> "Slice => {}" does?
Check the documentation for the DBI module, which you can get from 'perldoc
DBI' at a command-line shell (or
<http://search.cpan.org/~timb/DBI-1.607/DBI.pm> in a browser),
in particular the description for the selectall_arrayref method, which has
as its third form the following:
$ary_ref = $dbh->selectall_arrayref($statement, \%attr, @bind_values);
If the \%attr argument contains {Slice=>{}}, then the values will be
returned as a hash. From the documentation:
my $emps = $dbh->selectall_arrayref(
"SELECT ename FROM emp ORDER BY ename",
{ Slice => {} }
);
foreach my $emp ( @$emps ) {
print "Employee: $emp->{ename}\n";
}
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/