NAME
Oak::Filer::DBI - Filer to save/load data into/from DBI tables
SYNOPSIS
require Oak::Filer::DBI;
my $filer = new Oak::Filer::DBI
(
dbdriver => "mysql", # mandatory, any supported by DBI
database => "mydatabase", # mandatory
hostname => "hostname", # mandatory
table => "tablename", # mandatory to enable load and store.
# table to work in selects and updates
where => {primary => value},# this option must be passed to
# enable load and store functions.
# name and value of the keys to where sql clause
username => "dbusername", # optional
password => "userpasswd", # optional
options => { DBI OPTIONS }, # optional. A hash reference to DBI options
share => 1 # Share the db connection with other Oak::Filer::DBI objects
)
my $nome = $filer->load("nome");
$filer->store(nome => lc($nome));
DESCRIPTION
This module provides access for saving data into a DBI table, to be used by a Persistent descendant to save its data. Must pass table, prikey and privalue
OBJECT PROPERTIES
- datasource (readonly)
-
DBI datasorce string, used to create the connection and to share the connection with other objects, defined using the parameters passed to new.
- hostname,database,dbdriver,username,password,options
-
DBI options. See DBI documentation for more help.
- table, prikey, privalue
-
Used to implement load, store and list.
OBJECT METHODS
- constructor(PARAMS)
-
Called by new. You do not want do call it by yourself. Iniciate the database connection (if not (shared and exists)), prepare to work with determined table and register (setted by privalue).
- test_required_params(PARAMS)
-
Test if required params for the creation of the object exists. Called by constructor.
- register_connection
-
Register the connection for this object, implements the shared connection. Called by constructor.
- load(FIELD,FIELD,...)
-
Loads one or more properties of the selected DBI table with the selected WHERE statement. Returns a hash with the properties.
- store(FIELD=>VALUE,FIELD=>VALUE,...)
-
Saves the data into the selected table with the selected WHERE statement.
- quote
-
Quotes a string, using DBI->quote unless empty, else uses "''".
- make_where_statement
-
Returns the parameters for the where statement.
- release_connection
-
Called by DESTROY, releases the DBI connection. Disconnect if not sharing, or if sharing and the last using.
BUGS
Too early to know...
COPYRIGHT
Copyright (c) 2001 Daniel Ruoso <daniel@ruoso.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.