NAME
DBIx::HTMLView::DB - A generic DBI databse with SQL interface
SYNOPSIS
use DBIx::HTMLView; my $dbi=my $dbi=DB("DBI:mSQL:HTMLViewTester:localhost", "", "", Table ('Test', Id('id'), Str('testf'))); my $hist=$dbi->tab('Test')->list();
DESCRIPTION
The DB object is usualy only used to represent the top level database and to access the diffrent tabel objects. But all databse communications is routed through it so if you'r databse is not acting in the same way as mSQL (which is the database engine I've tested it with) you could subclass this object and override the methods the needs to be changed. Actually almost all SQL commands are generated here too, it is only the SELECT clause that is generated elsewhere.
METHODS
$dbi=DBIx::HTMLView::DB->new($db, $user, $pass, @tabs) =head2 $dbi=DBIx::HTMLView::DB->new($dbh, @tabs)
Creats a new databse represenation to the databse engine represented by the DBI data_source $db and connect's to it using $user and $pass as user name and pasword. @tabs is a list of the tabels contained in the database in form of DBIx::HTMLView::Table objects.
If you're db needs more initialising than a DBI connect you can initialise the connection yourself and then pass the dbh (as returned by the DBI->connect call) using the second form of the constructor.
The database connection will not be closed untill this object is destroyed.
$dbi->send($cmd)
Vill prepare and send the SQL command $cmd to the database and it dies on errors. The $sth is returned.
$dbi->tab($tab)
Returns the DBIx::HTMLView::Table object representing the table named $tab.
$dbi->tabs
Returns an array of DBIx::HTMLView::Table objects representing all the tables in the database.
$dbi->del($tab, $id)
Deletes the post with id $id form the table $tab (a DBIx::HTMLView::Table object).
$dbi->update($tab, $post)
Updates the data in the database of the post represented by $post (a DBIx::HTMLView::Post object) in the table $tab (a DBIx::HTMLView::Table object) with the data contained in the $post object.
$dbi->insert($tab, $post)
Insert the post $post (a DBIx::HTMLView::Post object)into the table $tab (a DBIx::HTMLView::Table object). This is the method to override if you need to change the way new post get's there id numbers assigned. This implementation assumes there excists a mSQL sequence on the table $tab which is asked for the next number.
$dbi->msql_create
Will create the tabels of the database using SQL commands that works with msql. The databse has to be created by hand using msqladmin or msqlconfig.