Big Sister Web Application Framework
|
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. |
int BigSWAF::DBCapsulator::add | ( | hashref | record | ) |
Add a record to the database/relation.
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.
size | The size of the sort cache. |
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.
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.
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.
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.
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.
filter | the filter (only the order set in the filter is obeyed) |
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.
filter | (optional) If filter is passed then only records matching this filter are returned. |
BigSWAF::DBCapsulator::update | ( | hashref | record | ) |
Update a record in the database/relation.