DBIx::HTMLView::DB - A generic DBI databse with SQL interface
use DBIx::HTMLView; my $dbi=my $dbi=DB("DBI:mSQL:HTMLViewTester:localhost", "", "", Table ('Test', Id('id'), Str('testf'))); my $hist=$dbi->tab('Test')->list();
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.
This class is intended as a generic base class it is then inherited by engine specifik classes such as DBIx::HTMLView::msqlDB and DBIx::HTMLView::mysqlDB. If you plan to use this with another database engine you'll probably have to atleast overide the insert sub to handle the assignmet of id values to new posts correctly.
Creates a new database representation to the database 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 tables contained in the database in form of DBIx::HTMLView::Table objects.
If you'r 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.
Will prepare and send the SQL command $cmd to the database and it dies on errors. The $sth is returned.
After this method has been called all sql queries will be printed instead of sent to the database.
Returns the DBIx::HTMLView::Table object representing the table named $tab.
Returns an array of DBIx::HTMLView::Table objects representing all the tables in the database.
Escapes the supplied string to be valid inside an SQL command. That is, it changes the string q[I'm a string] to q['I\'m a string'];
Deletes the post with id $id form the table $tab (a DBIx::HTMLView::Table object).
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.
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 their id numbers assigned. This method should also make sure to set the id fld of $post to the id assigned to it.
Will create the tables of the database using SQL commands that works with msql. The database has to be created by hand using msqladmin or msqlconfig.
Creates the table $table, a DBIx::HTMLView::Table object, using SQL commands that works with msql.
Returns the SQL type string used for the type $type of the Fld $fld. $type should be one of "Id", "Int", "Str", "Text", "Bool", "Date" and $fld should be a DBIx::HTMLView::Fld object.