internal package Foswiki::Plugins::DBConnectorPlugin
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
System 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
System 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"
https://puw.nkwiki.de/bin/rest/DBConnectorPlugin/createdb?topic=TheWeb.WebHome