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

When writing raw DBI code there is a huge lacking of core features that other more advanced libraries provide, such as DBIx::Class. These missing features are:

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, yet you still get many of these great benefits.

Even with this module you will often need to write raw DBI code, as DBIx::Meld isn't meant to be the one tool that rules them all. Instead, DBIx::Meld is meant to simplify the majority of the DBI work you do, but not all of it.

YAORM

This module is not "Yet Another ORM". The point of this module is that *it is not an ORM*. It is ORMish because it has some aspects that act similarly to the ORMs available to us today. But, that is as deep as it goes.

If you want an ORM, try out DBIx::Class. It is superb.

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'});
$meld->update('users', {email => 'joe@example.com'}, {user_id => 123});
$meld->delete('users', {status => 0});
# etc...

This trait provides access to most of SQL::Abstract's methods as methods on DBIx::Meld. Ready more at DBIx::Meld::Traits::SQLAbstract.

DateTimeFormat

my $format_class = $meld->datetime_formatter();
$meld->format_datetime( DateTime->now() );
$meld->format_date( 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.
Support pluggable traits so that other CPAN authors can release distros that easly plug in and add functionality.

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.