Alzabo::Runtime::Cursor - Base class for Alzabo cursors


Alzabo documentation Contained in the Alzabo distribution.

Index


Code Index:

NAME

Top

Alzabo::Runtime::Cursor - Base class for Alzabo cursors

SYNOPSIS

Top

  use Alzabo::Runtime::Cursor;

DESCRIPTION

Top

This is the base class for cursors.

METHODS

Top

new

Virtual method.

all_rows

Virtual method.

reset

Resets the cursor so that the next next call will return the first row of the set.

count

Returns the number of rows returned by the cursor so far.

next_as_hash

Returns the next row or rows in a hash, where the hash key is the table name and the hash value is the row object.

AUTHOR

Top

Dave Rolsky, <autarch@urth.org>


Alzabo documentation Contained in the Alzabo distribution.

package Alzabo::Runtime::Cursor;

use strict;
use vars qw($VERSION);

use Alzabo::Runtime;

$VERSION = 2.0;

1;

sub new
{
    shift->_virtual;
}

sub next
{
    shift->_virtual;
}

sub all_rows
{
    shift->_virtual;
}

sub _virtual
{
    my $self = shift;

    my $sub = (caller(1))[3];
    Alzabo::Exception::VirtualMethod->throw
            ( error =>
              "$sub is a virtual method and must be subclassed in " . ref $self );
}

sub reset
{
    my $self = shift;

    $self->{statement}->execute( $self->{statement}->bind );

    $self->{count} = 0;
}

sub count
{
    my $self = shift;

    return $self->{count};
}

sub next_as_hash
{
    my $self = shift;

    my @next = $self->next or return;

    return map { defined $_ ? ( $_->table->name => $_ ) : () } @next;
}

__END__