NAME
DBIx::Meld::ResultSet - An ORMish representation of a SQL query.
SYNOPSIS
$resultset->connector->run(sub{ ... });
$resultset->meld->connector->run(sub{ ... });
my $abstract = $rs->abstract();
my $old_rs = $meld->resultset('users')->search({ status => 0 });
my $new_rs = $old_rs->search({ age > 18 });
print 'Disabled adults: ' . $new_rs->count() . "\n";
$rs->insert({ user_name => 'joe_bob' });
$rs->update({ email => 'joe@example.com' });
$rs->delete();
my $row = $rs->array_row(['user_name', 'email']);
print $row->[0]; # user_name
print $row->[1]; # email
my $row = $rs->hash_row(); # defaults to '*' (all columns)
print $row->{user_name};
my $rows = $rs->array_of_array_rows(['user_name', 'user_id']);
foreach my $row (@$rows) {
print $row->[0] . "\n";
}
my $rows = $rs->array_of_hash_rows(['user_name', 'user_id']);
foreach my $row (@$rows) {
print $row->{user_name} . "\n";
}
my $rows = $rs->hash_of_hash_rows('user_id', ['user_id', 'user_name', 'email']);
foreach my $user_id (keys %$rows) {
print "$user_id: $rows->{$user_id}->{email}\n";
}
print $rs->count() . "rows!\n";
my $user_names = $rs->column('user_name');
foreach my $user_name (@$user_names) { ... }
my ($sth, @bind) = $rs->select_sth(['user_id', 'user_name']);
my $insert_sth;
foreach my $user_name (qw( jsmith bdoe )) {
my $fields = { user_name=>$user_name };
$insert_sth ||= $rs->insert_sth( $fields );
$insert_sth->execute( $rs->bind_values( $fields ) );
}
print $rs->total_entries();
print $rs->pager->total_entries();
DESCRIPTION
This class is a very lightweight wrapper around DBIx::Meld. All it does is remember the table name for all of the SQL::Abstract queries, like update(), and provides a way to progressively build a SQL query, much like DBIx::Class::ResultSet.
TRAITS
This module's features are all provided by traits. If you need details about this module's API, then you'll want to read up on the relevant trait.
Meld
Provides the meld() method for other traits to use. Ready more at DBIx::Meld::Traits::ResultSet::Meld.
Abstract
Additional simplifications to the various insert/update/delete/select calls as well as the ability to search() on a resultset. Ready more at DBIx::Meld::Traits::ResultSet::Abstract.
Pager
Provides the ability to page a resultset. Ready more at DBIx::Meld::Traits::ResultSet::Pager.
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.