| DBIx-Custom documentation | view source | Contained in the DBIx-Custom distribution. |
allfetchfetch_allfetch_firstfetch_hashfetch_hash_allfetch_hash_firstfetch_hash_multifetch_multifilterfilter_off EXPERIMENTALfilter_on EXPERIMENTALonestashtype_rule EXPERIMENTALtype_rule_off EXPERIMENTALtype_rule_on EXPERIMENTALtype_rule1_off EXPERIMENTALtype_rule1_on EXPERIMENTALtype_rule2_off EXPERIMENTALtype_rule2_on EXPERIMENTAL
DBIx::Custom::Result - Result of select statement
# Result
my $result = $dbi->select(table => 'book');
# Fetch a row and put it into array reference
while (my $row = $result->fetch) {
my $author = $row->[0];
my $title = $row->[1];
}
# Fetch only a first row and put it into array reference
my $row = $result->fetch_first;
# Fetch all rows and put them into array of array reference
my $rows = $result->fetch_all;
# Fetch a row and put it into hash reference
while (my $row = $result->fetch_hash) {
my $title = $row->{title};
my $author = $row->{author};
}
# Fetch only a first row and put it into hash reference
my $row = $result->fetch_hash_first;
my $row = $result->one; # Same as fetch_hash_first
# Fetch all rows and put them into array of hash reference
my $rows = $result->fetch_hash_all;
my $rows = $result->all; # Same as fetch_hash_all
filters my $filters = $result->filters;
$result = $result->filters(\%filters);
Filters.
sth my $sth = $reuslt->sth
$result = $result->sth($sth);
Statement handle of DBI.
DBIx::Custom::Result inherits all methods from Object::Simple and implements the following new ones.
allmy $rows = $result->all;
Same as fetch_hash_all.
fetchmy $row = $result->fetch;
Fetch a row and put it into array reference.
fetch_allmy $rows = $result->fetch_all;
Fetch all rows and put them into array of array reference.
fetch_firstmy $row = $result->fetch_first;
Fetch only a first row and put it into array reference, and finish statment handle.
fetch_hashmy $row = $result->fetch_hash;
Fetch a row and put it into hash reference.
fetch_hash_allmy $rows = $result->fetch_hash_all;
Fetch all rows and put them into array of hash reference.
fetch_hash_firstmy $row = $result->fetch_hash_first;
Fetch only a first row and put it into hash reference, and finish statment handle.
fetch_hash_multimy $rows = $result->fetch_hash_multi(5);
Fetch multiple rows and put them into array of hash reference.
fetch_multimy $rows = $result->fetch_multi(5);
Fetch multiple rows and put them into array of array reference.
filter $result->filter(title => sub { uc $_[0] }, author => 'to_upper');
$result->filter([qw/title author/] => 'to_upper');
Set filter for column.
You can use subroutine or filter name as filter.
This filter is executed after type_rule filter.
filter_off EXPERIMENTAL$result = $result->filter_off;
Turn filtering by filter method off.
By default, filterin is on.
filter_on EXPERIMENTAL$result = $resutl->filter_on;
Turn filtering by filter method on.
By default, filterin is on.
onemy $row = $result->one;
Same as fetch_hash_first.
stash my $stash = $result->stash;
my $foo = $result->stash->{foo};
$result->stash->{foo} = $foo;
Stash is hash reference for data.
type_rule EXPERIMENTAL # Merge type rule
$result->type_rule(
# DATE
9 => sub { ... },
# DATETIME or TIMESTAMP
11 => sub { ... }
);
# Replace type rule(by reference)
$result->type_rule([
# DATE
9 => sub { ... },
# DATETIME or TIMESTAMP
11 => sub { ... }
]);
This is same as DBIx::Custom's type_rule's <from>.
type_rule_off EXPERIMENTAL$result = $result->type_rule_off;
Turn from1 and from2 type rule off.
By default, type rule is on.
type_rule_on EXPERIMENTAL$result = $result->type_rule_on;
Turn from1 and from2 type rule on.
By default, type rule is on.
type_rule1_off EXPERIMENTAL$result = $result->type_rule1_off;
Turn from1 type rule off.
By default, type rule is on.
type_rule1_on EXPERIMENTAL$result = $result->type_rule1_on;
Turn from1 type rule on.
By default, type rule is on.
type_rule2_off EXPERIMENTAL$result = $result->type_rule2_off;
Turn from2 type rule off.
By default, type rule is on.
type_rule2_on EXPERIMENTAL$result = $result->type_rule2_on;
Turn from2 type rule on.
By default, type rule is on.
| DBIx-Custom documentation | view source | Contained in the DBIx-Custom distribution. |