NAME

DBIx::Meld::Traits::ResultSet::Abstract - Provides SQL::Abstract methods to result sets.

ATTRIBUTES

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.

clauses

Additional clauses, such as order_by, limit, offset, etc.

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

$rs->insert({ user_name => 'joe_bob' });

update

$rs->update({ email => 'joe@example.com' });

delete

$rs->delete();

array_row

my $row = $rs->array_row(['user_name', 'email']);
print $row->[0]; # user_name
print $row->[1]; # email

hash_row

my $row = $rs->hash_row(); # defaults to '*' (all columns)
print $row->{user_name};

array_of_array_rows

my $rows = $rs->array_of_array_rows(['user_name', 'user_id']);
foreach my $row (@$rows) {
    print $row->[0] . "\n";
}

array_of_hash_rows

my $rows = $rs->array_of_hash_rows(['user_name', 'user_id']);
foreach my $row (@$rows) {
    print $row->{user_name} . "\n";
}

hash_of_hash_rows

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";
}

count

print $rs->count() . "rows!\n";

column

my $user_names = $rs->column('user_name');
foreach my $user_name (@$user_names) { ... }

select_sth

my ($sth, @bind) = $rs->select_sth(['user_id', 'user_name']);

insert_sth

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 ) );
}

bind_values

See insert_sth(), above.

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.