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

NAME

DBIx::Custom::Result - Resultset for DBIx::Custom

VERSION

Version 0.0101

SYNOPSIS

    # $result is DBIx::Custom::Result object
    my $dbi = DBIx::Custom->new;
    my $result = $dbi->query($sql_template, $param);
    
    while (my ($val1, $val2) = $result->fetch) {
        # do something
    }

OBJECT ACCESSORS

sth

    # Set and Get statement handle
    $self = $result->sth($sth);
    $sth  = $reuslt->sth

Statement handle is automatically set by DBIx::Custom. so you do not set statement handle.

If you need statement handle, you can get statement handle by using this method.

fetch_filter

    # Set and Get fetch filter
    $self         = $result->fetch_filter($sth);
    $fetch_filter = $result->fech_filter;

Statement handle is automatically set by DBIx::Custom. If you want to set your fetch filter, you set it.

no_fetch_filters

    # Set and Get no filter keys when fetching
    $self             = $result->no_fetch_filters($no_fetch_filters);
    $no_fetch_filters = $result->no_fetch_filters;

METHODS

fetch

    # Fetch row as array reference (Scalar context)
    $row = $result->fetch;
    
    # Fetch row as array (List context)
    @row = $result->fecth

    # Sample
    while (my $row = $result->fetch) {
        # do something
        my $val1 = $row->[0];
        my $val2 = $row->[1];
    }

fetch method is fetch resultset and get row as array or array reference.

fetch_hash

    # Fetch row as hash reference (Scalar context)
    $row = $result->fetch_hash;
    
    # Fetch row as hash (List context)
    %row = $result->fecth_hash

    # Sample
    while (my $row = $result->fetch_hash) {
        # do something
        my $val1 = $row->{key1};
        my $val2 = $row->{key2};
    }

fetch_hash method is fetch resultset and get row as hash or hash reference.

fetch_first

    # Fetch only first (Scalar context)
    $row = $result->fetch_first;
    
    # Fetch only first (List context)
    @row = $result->fetch_first;
    

This method fetch only first and finish statement handle

fetch_first_hash

    # Fetch only first as hash (Scalar context)
    $row = $result->fetch_first_hash;
    
    # Fetch only first as hash (Scalar context)
    @row = $result->fetch_first_hash;
    

This method fetch only first and finish statement handle

fetch_rows

    # Fetch multi rows (Scalar context)
    $rows = $result->fetch_rows($row_count);
    
    # Fetch multi rows (List context)
    @rows = $result->fetch_rows($row_count);
    
    # Sapmle 
    $rows = $result->fetch_rows(10);

fetch_rows_hash

    # Fetch multi rows as hash (Scalar context)
    $rows = $result->fetch_rows_hash($row_count);
    
    # Fetch multi rows as hash (List context)
    @rows = $result->fetch_rows_hash($row_count);
    
    # Sapmle 
    $rows = $result->fetch_rows_hash(10);

fetch_all

    # Fetch all row as array ref of array ref (Scalar context)
    $rows = $result->fetch_all;
    
    # Fetch all row as array of array ref (List context)
    @rows = $result->fecth_all;

    # Sample
    my $rows = $result->fetch_all;
    my $val0_0 = $rows->[0][0];
    my $val1_1 = $rows->[1][1];

fetch_all method is fetch resultset and get all rows as array or array reference.

fetch_all_hash

    # Fetch all row as array ref of hash ref (Scalar context)
    $rows = $result->fetch_all_hash;
    
    # Fetch all row as array of hash ref (List context)
    @rows = $result->fecth_all_hash;

    # Sample
    my $rows = $result->fetch_all_hash;
    my $val0_key1 = $rows->[0]{key1};
    my $val1_key2 = $rows->[1]{key2};

error

    # Get error infomation
    $error_messege = $result->error;
    ($error_message, $error_number, $error_state) = $result->error;

You can get get information. This is crenspond to the following.

    $error_message : $result->sth->errstr
    $error_number  : $result->sth->err
    $error_state   : $result->sth->state

finish

    # Finish statement handle
    $result->finish
    
    # Sample
    my $row = $reuslt->fetch; # fetch only one row
    $result->finish

You can finish statement handle.This is equel to

    $result->sth->finish;

AUTHOR

Yuki Kimoto, <kimoto.yuki at gmail.com>

Github http://github.com/yuki-kimoto

COPYRIGHT & LICENSE

Copyright 2009 Yuki Kimoto, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.