NAME

DBIx::Meld::ResultSet - An ORMish representation of a SQL query.

SYNOPSIS

my $rs = $meld->resultset('users');
my $disabled_users = $rs->search({ status => 0 });
print 'Number of disabled users: ' . $disabled_users->count() . "\n";

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.

ATTRIBUTES

meld

The DBIx::Meld object that this resultset is using. This attribute provides a proxy method to connector so that you can do:

$resultset->connector->run(sub{  ... });

Instead of:

$resultset->meld->connector->run(sub{ ... });

table

The name of the table that this resultset will be using for queries.

where

The where clause hash ref to be used when executing queries.

order_by

An order by value just like SQL::Abstract accepts.

rows

The number of rows to return or, if pageing, then number of rows per-page. Note that this does not limit the number of rows updated/deleted.

page

The page number. If set, then this resultset will become paged and you will be able to access the pager() attribute.

pager

A Data::Page object pre-populated based on page() and rows(). If page() has not been specified then trying to access page() will throw a fatal error.

The total_entries and last_page methods are proxied from the pager in to this class so that you can call:

print $rs->total_entries();

Instead of:

print $rs->pager->total_entries();

METHODS

my $old_rs = $meld->resultset('users')->search({ status => 0 });
my $new_rs = $old_rs->search({ age > 18 });
print 'Disabled adults: ' . $new_rs->count() . "\n";

Returns a new resultset object that overlays the passed in where clause on top of the old where clause, creating a new resultset. The original resultset's where clause is left unmodified.

insert

my $users = $meld->resultset('users');
$users->insert({ user_name => 'joe_bob' });

update

my $users = $meld->resultset('users');
$users->search({ user_name => 'joe_bob' })->update({ email => 'joe@example.com' });

delete

$meld->resultset('users')->search({ user_id => 12 })->delete();

array_row

my $row = $users->search({ user_id => 12 })->array_row(['user_name', 'email']);
print $row->[0]; # user_name
print $row->[1]; # email

hash_row

my $row = $users->search({ user_id => 12 })->hash_row('*');
print $row->{user_name};

array_of_array_rows

my $rows = $users->search({ status => 1 })->array_of_array_rows(['user_name']);
foreach my $row (@$rows) {
    print $row->[0] . "\n";
}

array_of_hash_rows

hash_of_hash_rows

count

column

select_sth

insert_sth

delete_sth

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.