NAME

DBIx::SimpleQuery::Object - An object containing the results of a DBIx::SimpleQuery::query.

SYNOPSIS

use DBIx::SimpleQuery;

DBIx::SimpleQuery::set_defaults({
    "dsn"      => "DBI:Pg:test_database",
    "user"     => "test_user",
    "password" => "test_password",
});

# Perform maintenance on users
foreach my $user (query "SELECT * FROM users") {
    my $user_id = $user->{"user_id"};

    # Does this user have a password?
    unless (query "SELECT * FROM passwords WHERE user_id = $user_id") {
        print "User $user_id does not have a password!\n";
    }

    # How many widgets do they have?
    my $widget_count = query "SELECT * FROM widgets WHERE user_id = $user_id";
    print "User $user_id has $widget_count widgets.\n";

    # Get their first and last widgets
    my $first_widget <<= query "SELECT * FROM widgets WHERE user_id = $user_id ORDER BY time";
    my $last_widget >>= query "SELECT * FROM widgets WHERE user_id = $user_id ORDER BY time";
}

DESCRIPTION

DBIx::SimpleQuery::Object is a background module that allows a programmer to interact with the results of a query without having to resort to a structure like:

my $first_row_id = @{$results_arrayhashref}->[0]->{"user_id"};

Instead, it overloads the stringify, boolify, and other -ify functions to return values that the programmer wants, without needing all of the extra markup.

It should never be generated directly, but only as a result of a DBIx::SimpleQuery::query call. Use the synopsis above to get some ideas of how it works.

AUTHOR

Steve Simms (ssimms@cpan.org)

COPYRIGHT

Copyright 2004 Steve Simms. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

DBI DBIx::SimpleQuery