Acrux-DBI
view release on metacpan or search on metacpan
lib/Acrux/DBI/Res.pm view on Meta::CPAN
package Acrux::DBI::Res;
use strict;
use utf8;
=encoding utf8
=head1 NAME
Acrux::DBI::Res - Results of your database queries
=head1 SYNOPSIS
use Acrux::DBI::Res;
my $res = Acrux::DBI::Res->new(sth => $sth);
$res->collection->map(sub { $_->{foo} })->shuffle->join("\n")->say;
=head1 DESCRIPTION
Class to works with results of your database queries
=head2 new
my $res = Acrux::DBI::Res->new( sth => $sth, dbi => $dbi );
Construct a new Acrux::DBI::Res object
=head1 ATTRIBUTES
This method implements the following attributes
=head2 dbi
my $dbi = $res->dbi;
$res = $res->dbi(Acrux::DBI->new);
L<Acrux::DBI> object these results belong to.
=head2 sth
my $sth = $res->sth;
$res = $res->sth($sth);
L<Acrux::DBI> statement handle results are fetched from
=head1 METHODS
This class implements the following methods
=head2 affected_rows
my $affected = $res->affected_rows;
Number of affected rows by the query. For example
UPDATE testtable SET id = 1 WHERE id = 1
would return 1
=head2 array
my $array = $res->array;
Fetch one row from L</"sth"> and return it as an array reference
# [
# 'foo', 'bar', 'baz'
# ]
See also L<CTK::DBI/record>
=head2 arrays
my $arrays = $res->arrays;
Fetch all rows from L</"sth"> and return them as an array of arrays
( run in 0.570 second using v1.01-cache-2.11-cpan-ceb78f64989 )