Big Sister Web Application Framework
Classes | List of all members
BigSWAF::DBCapsulator Class Reference
Inheritance diagram for BigSWAF::DBCapsulator:
BigSWAF::DBCapsulator::DBI BigSWAF::DBCapsulator::Null BigSWAF::DBCapsulator::SearchFilter BigSWAF::DBCapsulator::DBI_CSV

Classes

class  DBI
class  DBI_CSV
class  Null
class  SearchFilter
 Search Filter encapsulation. More...

Public Class Methods

DBCapsulator database (scalar db)
 Opens a connection to the given database.
 connect (hashref dbcfg)
 Connect to a database using the given database connection.

Public Object Methods

hashref dbcfg (hashref dbcfg)
 Get/set the configuration of the current database connection.
int search (BigSWAF::DBCapsulator::SearchFilter filter)
 Search the database/relation for records matching the given filter.
hashref getnext ()
 Get the next result record of a previous search().
int add (hashref record)
 Add a record to the database/relation.
 delete (hashref record)
 Remove a record from the database/relation.
 update (hashref record)
 Update a record in the database/relation.
retval close ()
 Closes the database connection.
hash getnext_locallysorted (SearchFilter filter)
 Returns the next record from a search.
void clear_sortcache (scalar size)
 Clears and setup the cache used by getnext_locallysorted().
retval schema (scalar name)

Public Functions

retval config (scalar cfg)
 Read a config file defining the data connections.
retval schemadir (scalar dir)
 Set the directory where DBCapsulator will find meta information for the tables.
retval error (scalar msg)
 Prints an error message.

Member Function Documentation

int BigSWAF::DBCapsulator::add ( hashref  record)

Add a record to the database/relation.

Returns
1 if successful, 0 otherwise
void BigSWAF::DBCapsulator::clear_sortcache ( scalar  size)

Clears and setup the cache used by getnext_locallysorted().

It is good style to clear the cache before you first use getnext_locallysorted() on a started search.

Parameters
sizeThe size of the sort cache.
See Also
getnext_locallysorted
retval BigSWAF::DBCapsulator::close ( )

Closes the database connection.

Reimplemented in BigSWAF::DBCapsulator::DBI, and BigSWAF::DBCapsulator::Null.

retval BigSWAF::DBCapsulator::config ( scalar  cfg)

Read a config file defining the data connections.

BigSWAF::DBCapsulator::connect ( hashref  dbcfg)

Connect to a database using the given database connection.

This method is usually called by database() with the information found in the config file.

Sub classes usually will want to override this method and implement their own connection method.

Returns
a database connection
DBCapsulator BigSWAF::DBCapsulator::database ( scalar  db)

Opens a connection to the given database.

database() will search the config file set via config() for the named database, and set up an appropriate database connection.

Returns
database connection
hashref BigSWAF::DBCapsulator::dbcfg ( hashref  dbcfg)

Get/set the configuration of the current database connection.

BigSWAF::DBCapsulator::delete ( hashref  record)

Remove a record from the database/relation.

Returns
1 if successful, 0 otherwise
retval BigSWAF::DBCapsulator::error ( scalar  msg)

Prints an error message.

hashref BigSWAF::DBCapsulator::getnext ( )

Get the next result record of a previous search().

The record is a hash with the keys being field names and values being the field values.

Returns
result record, undef if none is left

Reimplemented in BigSWAF::DBCapsulator::DBI, and BigSWAF::DBCapsulator::Null.

hash BigSWAF::DBCapsulator::getnext_locallysorted ( SearchFilter  filter)

Returns the next record from a search.

However, records are first read into a local cache of the given size, then sorted within this cache and retrieved only after that. Records that are out of order after this local sort are silently dropped.

Parameters
filterthe filter (only the order set in the filter is obeyed)
Returns
the next record
See Also
clear_sortcache()
Todo:
implement this :-)
retval BigSWAF::DBCapsulator::schema ( scalar  name)
retval BigSWAF::DBCapsulator::schemadir ( scalar  dir)

Set the directory where DBCapsulator will find meta information for the tables.

int BigSWAF::DBCapsulator::search ( BigSWAF::DBCapsulator::SearchFilter  filter)

Search the database/relation for records matching the given filter.

The results can be retrieved using getnext(). Each connection therefore only accepts one search at a time. Setting up a new search via search() implies that the old search is lost.

Parameters
filter(optional) If filter is passed then only records matching this filter are returned.
Returns
1 if successful, 0 otherwise
BigSWAF::DBCapsulator::update ( hashref  record)

Update a record in the database/relation.

Returns
1 if successful, 0 otherwise

The documentation for this class was generated from the following file: