The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Carrot::Productivity::Text::Placeholder::Miniplate::SQL::Result - construct field lists for SELECT and format the result set

SYNOPSIS

        $class_names->provide(
                my $template_class = '::Productivity::Text::Placeholder::Template');

        my $template = $template_class->constructor(
                my $sql_result = '::SQL::Result');
        $sql_result->placeholder_re('^fld_(\w+)$');
        $template->compile('<td>[=fld_some_name=]</td>');

        my $statement = "SELECT ". $sql_result->field_list->(). " FROM some_table";
        print "$statement\n";

        # my $rows = $dbh->selectall_arrayref($statement, ...);
        # foreach my $row (@$rows) {...
        my $row = [7, 8, 9];
        $sql_result->set_subject($row);

        print ${$template->execute()}, "<-\n";

DESCRIPTION

Provides placeholder placeholders based on a configurable RE, which needs one capture group. Placeholders are substituted by the captured pattern. A list of captures can be obtained, from which SQL statements can be constructed.

METHOD REFERENCE (API)

subject($row)

Sets or gets the retrieved row.

field_lists

Gets an anonymous sub to return the captured placeholder parts dynamically.

placeholder_re

The regular expression for matching placeholders.

KNOWN BUGS AND LIMITATIONS

This is the first public release.

AUTHOR

Winfried Trumper <pub+perl(a)wt.tuxomania.net>

COPYRIGHT AND LICENSE

Copyright (C) 2011 Winfried Trumper

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