Aran Clary Deltac

NAME

DBIx::ResultSet::Connector - Access result sets via DBIx::Connector.

SYNOPSIS

    use DBIx::ResultSet::Connector;
    
    # Same arguments as DBI and DBIx::Connector.
    my $connector = DBIx::ResultSet::Connector->new(
        $dsn, $user, $pass,
        $attr, #optional
    );
    
    # Get a resultset for the users table.
    my $users_rs = $connector->resultset('users');
    
    # Use the proxied txn() method to do a bunch of inserts
    # within a single transaction that will automatically
    # re-connect if the DB connection is lost during the
    # transaction (fixup).
    $connector->txn(fixup => sub{
        foreach my $user_name (@new_user_names) {
            $users_rs->insert({ user_name=>$user_name });
        }
    });
    
    # Format dates and times in the DB's format.
    print $connector->format_datetime( DateTime->now() );
    print $connector->format_date( DateTime->now() );
    print $connector->format_time( DateTime->now() );

DESCRIPTION

This module is a lightweight wrapper around SQL::Abstract, SQL::Abstract::Limit, DBIx::Connector, and the various DateTime::Format modules. This module is primarly a factory for creating new DBIx::ResultSet objects via the resultset() method.

METHODS

resultset

    # Get a resultset for the users table.
    my $users_rs = $connector->resultset('users');

Returns a new DBIx::ResultSet object tied to the specified table.

format_datetime

    print $connector->format_datetime( DateTime->now() );

Returns the date and time in the DB's format.

format_date

    print $connector->format_date( DateTime->now() );

Returns the date in the DB's format.

format_time

    print $connector->format_time( DateTime->now() );

Returns the time in the DB's format.

ATTRIBUTES

dbix_connector

Holds the underlying DBIx::Connector object. The dbh(), run(), txn(), and svp() methods are proxied.

abstract

A SQL::Abstract::Limit object for use by DBIx::ReesultSet.

datetime_formatter

    my $formatter = $connector->datetime_formatter();
    print $formatter->format_date( DateTime->now() );

This returns the DateTime::Format::* class that is appropriate for your database connection.

AUTHOR

Aran Clary Deltac <bluefeet@gmail.com>

LICENSE

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