The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

DBIx::Custom::Result - Result of select statement

SYNOPSIS

Get the result of select statement.

    # Result
    my $result = $dbi->select(table => 'books');

Fetch row into array.

    # Fetch a row into array
    while (my $row = $result->fetch) {
        my $author = $row->[0];
        my $title  = $row->[1];
        
    }
    
    # Fetch only a first row into array
    my $row = $result->fetch_first;
    
    # Fetch multiple rows into array of array
    while (my $rows = $result->fetch_multi(5)) {
        my $first_author  = $rows->[0][0];
        my $first_title   = $rows->[0][1];
        my $second_author = $rows->[1][0];
        my $second_value  = $rows->[1][1];
    
    }
    
    # Fetch all rows into array of array
    my $rows = $result->fetch_all;

Fetch row into hash.

    # Fetch a row into hash
    while (my $row = $result->fetch_hash) {
        my $title  = $row->{title};
        my $author = $row->{author};
        
    }
    
    # Fetch only a first row into hash
    my $row = $result->fetch_hash_first;
    
    # Fetch multiple rows into array of hash
    while (my $rows = $result->fetch_hash_multi(5)) {
        my $first_title   = $rows->[0]{title};
        my $first_author  = $rows->[0]{author};
        my $second_title  = $rows->[1]{title};
        my $second_author = $rows->[1]{author};
    }
    
    # Fetch all rows into array of hash
    my $rows = $result->fetch_hash_all;

ATTRIBUTES

Filters when a row is fetched. This overwrites default_filter.

filters

    my $filters = $result->filters;
    $result     = $result->filters(\%filters);

Resistered filters.

sth

    my $sth = $reuslt->sth
    $result = $result->sth($sth);

Statement handle of DBI.

METHODS

DBIx::Custom::Result inherits all methods from Object::Simple and implements the following new ones.

all

    my $rows = $result->all;

This is alias for fetch_hash_all.

end_filter

    $result = $result->end_filter(title  => 'to_something',
                                     author => 'to_something');

    $result = $result->end_filter([qw/title author/] => 'to_something');

End filters. These each filters is executed after the filters applied by apply_filter of DBIx::Custom or filter method.

fetch

    my $row = $result->fetch;

Fetch a row into array.

fetch_all

    my $rows = $result->fetch_all;

Fetch all rows into array of array.

fetch_first

    my $row = $result->fetch_first;

Fetch only a first row into array and finish statment handle.

fetch_hash

    my $row = $result->fetch_hash;

Fetch a row into hash

fetch_hash_all

    my $rows = $result->fetch_hash_all;

Fetch all rows into array of hash.

fetch_hash_first

    my $row = $result->fetch_hash_first;

Fetch only first row into hash and finish statment handle.

fetch_hash_multi

    my $rows = $result->fetch_hash_multi(5);
    

Fetch multiple rows into array of hash Row count must be specified.

fetch_multi

    my $rows = $result->fetch_multi(5);
    

Fetch multiple rows into array of array. Row count must be specified.

filter

    $result = $result->filter(title  => 'to_something',
                              author => 'to_something');

    $result = $result->filter([qw/title author/] => 'to_something');

Filters. These each filters override the filters applied by apply_filter of DBIx::Custom.

one

    my $row = $result->one;

This is alias for fetch_hash_first.

remove_end_filter

    $result->remove_end_filter;

Remove end filter.

remove_filter

    $result->remove_filter;

Remove filter. End filter is not removed.

stash

    my $stash = $result->stash;
    my $foo = $result->stash->{foo};
    $result->stash->{foo} = $foo;

Stash is hash reference to save your data.