DBIx-Lite

 view release on metacpan or  search on metacpan

lib/DBIx/Lite/ResultSet.pm  view on Meta::CPAN


    my $authors = $dbix->table('authors')->select('name')->distinct;
    my $authors = $dbix->table('authors')->select('name')->distinct('name');
    my $authors = $dbix->table('authors')->select('name')->distinct(\'lower(name)');

=head2 for_update

This method accepts no argument. It enables the addition of the SQL C<FOR UPDATE>
clause at the end of the query, which allows to fetch data and lock it for updating.
It returns a L<DBIx::Lite::ResultSet> object to allow for further method chaining.
Note that no records are actually locked until the query is executed with L<single()>,
L<all()> or L<next()>.

    $dbix->txn(sub {
        my $author = $dbix->table('authors')->find($id)->for_update->single
            or die "Author not found";
        
        $author->update({ age => 30 });
    });

This is actually a shortcut for the L<for> method described below:



( run in 0.966 second using v1.01-cache-2.11-cpan-49f99fa48dc )