NAME
DBIx::Meld - An ORMish amalgamation.
SYNOPSIS
use DBIx::Meld;
my $meld = DBIx::Meld->new( $dsn, $user, $pass );
$meld->insert( 'users', {user_name => 'smith023'} );
my $rows = $meld->array_of_hash_rows( 'users', ['user_name', 'email'], {status => 1} );
foreach my $row (@$rows) {
print "$row->{user_name}: $row->{email}\n";
}
# or, in a more ORMish fashion:
my $users = $meld->resultset('users');
$users->insert({user_name => 'smith023'});
my $rows = $users->search({ status => 1 })->array_of_hash_rows(['user_name', 'email']);
DESCRIPTION
This module combines the features of DBIx::Connector, SQL::Abstract, and the various DateTime::Format modules, with some of the design concepts of DBIx::Class.
WHY
DBIx::Class is a really great tool. But, it doesn't fit some situations as it is too heavyweight in other situations. In these situations, where you find yourself having to write raw DBI calls, you are suddenly left without all of the great features that DBIx::Class provides, such as:
- Robust connection and transation handling.
- Greatly reduced need to write raw SQL.
- Database independent date and time handling.
- Ability to progressively construct queries using resultsets.
So, the intent of this module is to fill this gap. With this module you are still dealing with low-level DBI calls, but you get many of the great benefits that DBIx::Class provides.
CONSTRUCTOR
There are several ways to create a new DBIx::Meld object. The most common way is to call it just like DBIx::Connector:
my $meld = DBIx::Meld->new( $dsn, $user, $pass, $attrs ); # $attrs is optional
Or you can do it using name/value pairs:
my $meld = DBIx::Meld->new( connector => [$dsn, $user, $pass] );
The connector attribute may also be an already blessed object:
my $connector = DBIx::Connector->new( $dsn, $user, $pass );
my $meld = DBIx::Meld->new( connector => $connector );
TRAITS
DBIxConnector
$meld->txn(sub{ ... });
# This does the same thing:
$meld->connector->txn(sub{ ... });
This traite provides all of DBIx::Connector's methods as methods on DBIx::Meld. Ready more at DBIx::Meld::Traits::DBIxConnector.
SQLAbstract
$meld->insert('users', {user_name => 'smith023'});
This trait provides access to most of SQL::Abstract's methods as methods on DBIx::Meld. Ready more at DBIx::Meld::Traits::SQLAbstract.
DateTimeFormat
$meld->format_datetime( DateTime->now() );
This trait provides access to the appropriate DateTime::Format module and provides helper methods on DBIx::Meld. Read more at DBIx::Meld::Traits::DateTimeFormat.
ResultSet
my $user = $meld->resultset('users');
This trait provides the resultset() method which, when given a table name, returns an DBIx::Meld::ResultSet object. Read me at DBIx::Meld::Traits::ResultSet.
TODO
- Support GROUP BY, HAVING, and LIMIT (and Data::Page?) clauses when selecting data.
- Integrate DBIC's well-tested auto-generated ID retrieval code. This can be tricky since each DB does it in a different way (/looks at Oracle). Then, insert() can return that ID.
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.