NAME

Konstrukt::Plugin::sql - Perform SQL queries.

SYNOPSIS

SELECT queries

<!-- put query results into a template using the dbi default settings defined in your konstrukt.settings
     see the Konstrukt::DBI documentation for the configuration of the default settings -->
<& sql query="SELECT * FROM some_table" template="list_layout.template" / &>
<!-- you must have a list <+@ sql @+> in your template file to which the results are passed.
     the fields inside the list must be named like the columns in your query. -->

<!-- but you may also define the listname yourself -->
<& sql query="SELECT * FROM some_table" template="list_layout.template" list="some_list_name" / &>
<!-- then you should have a list <+@ some_list_name @+> in your template file. -->

<!-- using custom connection settings -->
<& sql query="..." template="..." source="dbi_dsn" user="username" pass="password" / &>

<!-- manually define the template.
     more flexible, but a bit slower.
     #TODO: actually this one doesn't work correctly at the moment due to a bug in the template plugin -->
<& template src="some.template" &>
	<& sql query="SELECT some, columns FROM some_table" list="query_results" / &>
	<& sql query="SELECT some, columns FROM some_other_table" list="other_query_results" / &>
	<$ some $>other<$ / $>
	<$ fields $>here<$ / $>
<& / &>
<!-- in this mode, the plugin will return the result as a field list, which may
     be used in template. the returned result will look like this: -->
<@ list_name @>
	<$ field1 $>value1a<$ / $><$ field2 $>value2a<$ / $>
	<$ field1 $>value1b<$ / $><$ field2 $>value2b<$ / $>
	...
<@ / @>
<!-- so you can put this data into a template as done in the example above. -->

Other queries

<!-- some query that won't return result data -->
<& sql query="DELETE FROM some_table WHERE id=23" / &>

DESCRIPTION

This plugin allows an easy integration of SQL queries. Usually combined with templates to display the results.

The usage is explained in the "SYNOPSIS".

METHODS

execute_again

Yes, this plugin may return dynamic nodes (i.e. template nodes).

prepare

SQL-queries are very volatile data. We don't want to cache it...

Parameters:

  • $tag - Reference to the tag (and its children) that shall be handled.

execute

Put out the date.

Parameters:

  • $tag - Reference to the tag (and its children) that shall be handled.

AUTHOR

Copyright 2006 Thomas Wittek (mail at gedankenkonstrukt dot de). All rights reserved.

This document is free software. It is distributed under the same terms as Perl itself.

SEE ALSO

Konstrukt::Plugin, Konstrukt