NAME

Config::Backend::SQL - An SQL backend for Config::Frontend.

ABSTRACT

Config::Backend::SQL is an SQL backend for Config::Frontend. It handles a table $table with identifiers that are assigned values. The identifiers are specified on a per user basis. Config::Backend::SQL tries to get the user account of the user self.

Description

Each call set() will immediately result in a commit to the database.

new(DSN => ...,DBUSER => ..., DBPASS =>, [TABLE => ...]) --> Config::Backend::SQL

Invoked with a valid DSN, DBUSER and DBPASS combination, will return a Config::Backend::SQL object that is connected to the database.

TABLE defaults to conf_table.

This function will try to create a TABLE table in the given DSN, if it does not exist. This will probably succeed for DBD drivers Pg, mysql and sqlite.

Creating the table $table in your database

If this module cannot create a table for you, because it doesn't know the database you are using, you can create your own (or send modifications to the author). The table used has following form:

CREATE TABLE $table(uid varchar,var varchar,value varchar)

The form presented here is a PostgreSQL form. You will want at least following specifications for uid, var and value:

uid    varchar(1024)
var    varchar(250)
value  text, bigtext, mediumtext, varchar(1000000000), etc.

You may also want an index on $table, like this one:

"CREATE INDEX $table"."_idx ON $table(uid, var)"

DESTROY()

This function will disconnect from the database.

set(var,value) --> void

Sets config key var to value.

get(var) --> string

Reads var from config. Returns undef, if var does not exist. Returns the value of configuration item var, otherwise.

del(var) --> void

Delets var from the table.

variables() --> list of strings

Returns all variables in the configuraton backend.

SEE ALSO

Config::Frontend.

AUTHOR

Hans Oesterholt-Dijkema, <oesterhol@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2004 by Hans Oesterholt-Dijkema

This library is free software; you can redistribute it and/or modify it under LGPL.