Mark,
        I agree.  Instead of pointing out the intricacies of the docs to you I
think I'll comment on the point of your post...
        Yes, I think a selectall_hashref function would be a clean and concise
method that would improve the clarity of the DBI spec.

> -----Original Message-----
> From: Mark Stosberg [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, March 20, 2001 3:06 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: selectall_hashref, a future feature?
>
>
> [EMAIL PROTECTED] wrote:
> >
> > It's not undocumented.  First we look up
> > selectall_arrayref. We see:
> > ------------
> >   $ary_ref = $dbh->selectall_arrayref($statement, \%
> > attr);
> >
> > This utility method combines /prepare, /execute and
> > /fetchall_arrayref into a single call. It returns a
> > reference to an array containing a reference to an array
> > for each row of data fetched.
>
> I already knew how to do this using fetchall_arrayref, but I don't
> believe there is any documentation on how to do this one fell swoop:
>
> perldoc DBI | grep dbi_fetchall_arrayref_attr
>
> That returns no result, but it is explicitly mentioned mentioned
> in the code:
>
>     sub selectall_arrayref {
>         my ($dbh, $stmt, $attr, @bind) = @_;
>         my $sth = (ref $stmt) ? $stmt
>                               : $dbh->prepare($stmt, $attr);
>         return unless $sth;
>         $sth->execute(@bind) || return;
>         my $slice = $attr->{dbi_fetchall_arrayref_attr}; # typically undef
>         return $sth->fetchall_arrayref($slice);
>     }
>
> Based on the docs for fetchall_arrayref, I believe this would be the
> correct way to call it:
> $DBH->selectall_arrayref("SELECT * from FOO", {
> dbi_fetchall_arrayref_attr => {} });
>
> I can't find any other way to accomplish this with a single DBI
> statement, so I continue to think this is undocumented feature. :) (and
> one in need of a handy shortcut. :)
>
>   -mark
>
> personal website             }      Summersault Website Development
> http://mark.stosberg.com/    {      http://www.summersault.com/
>

Reply via email to