The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DBIx::QueryByName::QueryPool - Manages a pool of sql query descriptions

DESCRIPTION

An instance of DBIx::QueryByName::QueryPool stores the descriptions of all the queries that can be executed with corresponding instances of DBIx::QueryByName.

DO NOT USE DIRECTLY!

INTERFACE

This API is subject to change!

my $pool = DBIx::QueryByName::QueryPool->new();

Instanciate DBIx::QueryByName::QueryPool.

$pool->add_query(name => $name, sql => $sql, session => $session, result => $result, params => \@params);

Add a query to this pool. $result must be one of 'sth', 'scalar', 'hash', 'scalariterator', 'hashiterator'. Example:

    $pool->add_query(name => 'get_user_adress',
                     sql => 'SELECT adress FROM adresses WHERE firstname=? AND lastname=?',
                     result => 'sth',
                     params => [ 'firstname', 'lastname' ],
                     session => 'name_of_db_connection',
                    );
$pool->knows_query($name);

True if the pool already contains a query with that name. False otherwise.

my ($session,$sql,@params) = $pool->get_query($name);

Return the name of the database session, the sql code and the named parameters of the query named $name. Croak if no query with that name.