Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
HTML::Template::AssociUser:Contributed Perl DHTML::Template::Associate::DBI(3)

NAME
       HTML::Template::Associate::DBI -	HTML::Template::Associate DBI plugin

SYNOPSIS
	       This class is not intended to be	used directly but rather through a
	       HTML::Template::Associate. It provides concrete class functionality.

	       use DBI;
	       use HTML::Template;
	       use HTML::Template::Associate;

	       #initiliaze your	$dbh ...

	       my $results_foo = $dbh->selectall_hashref (
		       'SELECT foo FROM	bar WHERE baz =	?',
		       'foo_id',
		       {},
		       $baz
	       );

	       my $results_bar = $dbh->selectall_hashref (
		       'SELECT foo, bar	FROM bar WHERE baz = ?',
		       [ 'foo_id', 'bar_id' ] ,
		       {},
		       $baz
	       );

	       my $results_moo = $dbh->selectrow_hashref ( 'SELECT x, y	FROM z LIMIT 1'	);

	       my @results_array = $dbh->selectrow_array ( 'SELECT x FROM z' );

	       my $associate = HTML::Template::Associate->new( {
		       target => 'DBI',
		       create => [ {
				       results => $results_foo,
				       name => 'my_loop',
				       type => 'selectall_hashref'
			       }, {
				       results => $results_bar,
				       name => 'my_other_loop',
				       type => 'selectall_hashref'
			       }, {
				       results => $results_moo,
				       type => 'selectrow_hashref',
				       name => 'my_params'
			       }, {
				       results => \@results_array,
				       type => 'selectrow_array',
				       name => 'my_array_params'
			       }
		       ]
	       } );

	       my $template = HTML::Template->new (
		       filename	=> 'test.tmpl',
		       associate => [ $associate ],
		       die_on_bad_params => 0
	       );

	       print $template->output();

	       #sample.tmpl

	       <!-- TMPL_LOOP NAME="my_loop" -->
		       Foo is:<!-- TMPL_VAR NAME="foo" -->
	       <!-- /TMPL_LOOP -->

	       <!-- TMPL_LOOP NAME="my_other_loop" -->
		       Foo is:<!-- TMPL_VAR NAME="foo" -->
		       Bar is:<!-- TMPL_VAR NAME="bar" -->
	       <!-- /TMPL_LOOP -->

	       x is:<!-- TMPL_VAR NAME="my_params.x" -->
	       y is:<!-- TMPL_VAR NAME="my_params.y" -->

	       x via $dbh->selectrow_array is:<!-- TMPL_VAR NAME="my_array_params.0 -->

DESCRIPTION
	       This class is not intended to be	used directly but rather through a
	       HTML::Template::Associate. It provides concrete class functionality, it
	       will take specific DBI method results and reconstruct data structure
	       to the one appropriate for use by the HTML::Template.

	       Supported DBI method types
	       * selectall_hashref
	       * selectrow_hashref
	       * fetchall_hashref
	       * fetchrow_hashref
	       * selectall_arrayref
	       * selectcol_arrayref
	       * selectrow_array
	       * selectrow_arrayref
	       * fetchrow_array
	       * fetchrow_arrayref
	       * fetchall_arrayref

METHODS
       init
	   Initializes the mapper

       init_selectall_hashref
	   Transform using selectall_hashref return format.

       init_selectrow_hashref
	   Transform using selectrow_hashref return format.

       init_selectall_arrayref
	   Transform using selectall_arrayref return format.

       init_selectcol_arrayref
	   Transform using selectcol_arrayref return format.

BUGS
	       If you find any please report to	author.

SUPPORT
	       See License.

AUTHOR
	       Alex Pavlovic
	       alex.pavlovic@taskforce-1.com
	       http://www.taskforce-1.com

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

	       The full	text of	the license can	be found in the
	       LICENSE file included with this module.

SEE ALSO
	       HTML::Template::Associate HTML::Template::Associate::FormValidator perl(1).

POD ERRORS
       Hey! The	above document had some	coding errors, which are explained
       below:

       Around line 253:
	   You forgot a	'=back'	before '=head1'

perl v5.32.1			  2012-05-10 HTML::Template::Associate::DBI(3)

NAME | SYNOPSIS | DESCRIPTION | METHODS | BUGS | SUPPORT | AUTHOR | COPYRIGHT | SEE ALSO | POD ERRORS

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=HTML::Template::Associate::DBI&sektion=3&manpath=FreeBSD+13.0-RELEASE+and+Ports>

home | help