internal package Foswiki::Plugins::DBConnectorPlugin

See PublishedAPI for packages intended to be used by Plugin and Contrib authors, or browse all packages.
See also Developing plugins, Developer's Bible, Technical Overview

getValues( $web, $topic, @fields ) -> ( %result )

get values for out of the database
  • $web - Web name, required, will be used as table
  • $topic Topic name, required, will be used as identifier/key
  • $fields - reference on an array of field names, optional. This fields are fetched out of the db
  • $checkAccess if this is zero, access is not checked
Return: ( %result ) Result, a hashref with each fetched field-name as ke

if you want to fetch fields ('samplefield1','samplefield2') from WebHome you call it :
my $result getValues("System",'WebHome',('samplefield1','samplefield2'));
accessing results this way
print $result->{'bar'};

updateValues( $web, $topic, $fiedValuePairs ) -> ( )

get values for out of the database
  • $web - Web name, required, will be used as table
  • $topic Topic name, required, will be used as identifier/key
  • $fiedValuePairs reference to a hash, which has the field-name as key and the hash-value as field-value
  • $checkAccess if this is zero, access is not checked
Return: -

if you want to update fields ('samplefield1','samplefield2') from WebHome you call it :
my %pairs;
%pairs->{'samplefield1'} = 20;
%pairs->{'samplefield2'} = "myvalue1";
# Attention, you must use a reference!
updateValues("System",'WebHome',\%pairs);

sendQry( $query ) -> ( $results)

use this method to simply run querys on the database. You get a result like described by getValues
  • $query Complete SQL query;
Return: returning a hash which has an the topic-identiefer as key for each row fetch, for each of this values a hash is stored, by {fieldname} = value like in getValues

deleteEntry( $web, $topic ) -> ( )

deletes an entry out of the database $web, identiefied by $topic
  • $web - Web name, required, will be used as table
  • $topic Topic name, required, will be used as identifier/key

_createDB( $session ) -> ( )

if you want to create a initial table for a web, where informations can be stored for topics, you got to run this rest handler to initialize/create it. The query defined on topic DBConnectorPluginCreateTableQuery is used as a template for the query.
  • %TABLENAME% gets expanded to the corresponding Web, when you create the table;
  • %TOPICNAME% gets expanded to the topic. This should be actually always be a existing topic. In normal cases, this value is not needed in the template#
  • %DBCONTABLEKEYFIELD% gets expanded to the primary key which is defined in the Configuration-Center $Foswiki::cfg{Plugins}{DBConnectorPlugin}{TableKeyField}
_you can disallow the creatinof table with unchecking $Foswiki::cfg{Plugins}{DBConnectorPlugin}{allowCreatedb} in the Configuration-Center _ you call the rest handler this way, creating a data for the web "TheWeb"
http://cosmo.astro.umk.pl/foswiki/bin/rest/DBConnectorPlugin/createdb?topic=TheWeb.WebHome 

Topic revision: r1 - 19 Apr 2011, ProjectContributor
 
This site is powered by FoswikiCopyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki? Send feedback