NAME

Medvedb - MEDium Visualization Environment for DataBases


SYNOPSIS

Using XML firepower

        use medvedb;
        my $interface = new medvedb;
        $interface->cast_spell('desrciption.xml','application');

Using Perl warhammer

        use medvedb;
        my $interface = new medvedb;
        $interface->config({
                -db_user                => 'dbuser',
                -db_host                => 'localhost',
                -db_database            => 'mydatabase',
                -db_table               => 'mytable',
                -db_default_order       => 'name',
                -db_default_action      => 'show'
        });
        $interface->dbconnect();
        my $order = $interface->getorder();
        print $interface->htmlheader();
        my %show = (
                        -db_view        => {
                                ID      => ['id',       0],
                                Name    => ['name',     1],
                        },
                        -view_select=>  $order,
                        -act_sort=> "<SELF_URL>?order=",
                        -act_view=> "<SELF_URL??action=full&select=",
        );
        print $interface->print_view({'show'    => \%show});
        print $interface->htmlend;
        $interface->dbdisconnect;


DESCRIPTION

Medvedb module simplify building web and GUI* applications for access to database. Programmer or user simple specify content of database and Medvedb builds interace. There are some implicit rules for building interface so user do not need to tell everything about database. It the interace is not good user may specify more details.

There are two ways how to specify the interface:

1. Use Perl hash specification - good for programmer's but too complicated for normal user.

2. Use XML specification - good for normal user, but it's little bit weaker than Perl hash. It's very fast methode for building applications. (preffered)

GUI* - GUI support is not fully implemented now.

How it works

We have database server (eg. MySQL) adn we have web server (eg. Apache). We want to build simple but powerfull web interface to database. So we can write simple CGI script. Medvedb contains a lot of very common functions for building web interface. So, we can write CGI script useing Medvedb.

Interface specification is written in Perl. We use structure hash, because it's very powerfull. When we have hash we call function from Medvedb. Medvedb parse our request and sends SQL queries to database server. When it recieves data from server, it starts to build interface from database reply and our specificatio reply. After all reply is send to user.

Perl hash is cool, but not for everyone. When you want to rewrite hash you need to change program. This is not very clean solution, so we develop XML specification. You can write simple XML file that contains same information as Perl hash and result is same. Using XML file you don't destroy application code and it's more human readable than Perl hash.

Medvedb is well designed so you can change XML configuration to any type of configuration without hurting kernel. You only add interface that reads configuration and than transforms all requests to Perl hash.

Diagram: How it works

 = = = = = = = = = = = = = = = = = = 
 =  XML interface  ----> XML::Twig =
 =  specifivation        Parser    =
 = = = = = = = = = = = = = = = = = =
                           |
                           V
                        Perl Hash
                        specification  
                           |           
                           V          
          CGI           -------   ----> Query
      --> input -->    |Medvedb|        transform.  
User                   |kernel |           |
      <--  CGI  <--    |-------|           V
          optput       |format.|  <----  DBI:DBD   <--> DB
            ^           -------
           CSS


REQUIREMENTS

Perl - http://www.perl.org
DBI:DBD - http://dbi.perl.org
XML::Twig - http://www.xmltwig.org

Database server, web server.


METHODS

Fast building using XML

cast_spell(xml_file_name, application_name)

When XML is well formated you need only one command to build interface. xml_file_name is name of file where XML descrition is stored. Several application may be stored in one XML file, to invoke appropritiate application you need to specify allplicatio_name. No more commands are required to build interface.

miracle(xml_file_name);

Weaker from of cast_spell, it requires XML file where only one application is specified. No more commands are required to build interface.

Configuring module

config(cfg_hash)

For advanced configuring you need this function.

db_user
- username that is allowed to access to database

host
- name of host where is database server running

db_database
- name of database stored on database server

db_table
- name of default table

db_engine
- name of database engine driver (eg. mysql)

db_password
- password to access database

db_default_order
- name of column used for sorting of output

db_default_action
- name of action that is called when no other action specified

db_default_position
- n-th displayed position

db_default_select
- name of default selected column

db_default_asc
- default type of sorting (DESCENDENT=1, ASC=-1)

db_step
- number of rows displayed

html_author
- authors name used in html title

html_bgcolor
- HTML color using for background

html_encoding
- encoding of HTML page (eg. ISO-8859-2, UTF-8)

html_css
- CSS file required for HTML formating

html_lang
- HTML language (eg. sk_SK, en_US)

html_title
- default title of HTML page

Database connection

dbconnect()

Connects to database server.

dbdisconnect()

Close connection to database.

HTML

htmlheader()

Returns HTML header and begin of HTML page.

htmlend()

Returns end of HTML page.

bar(%hash)

Build bar containing name of keys and hyper link to values of hash

htmlbar(%hash)

Build bar containing referrences to subaplications (eg. show, full)

print_view(%hash)

Starts main proces of Medvedb. Keys of hash are names of subapplications. Values are reference to hash specification of subaplications. It builds the view using appropritiate specification.


ABOUT

web: http://medvedb.sourceforge.net


AUTHOR

Juraj Michalek


SEEL ALSO

perl, CGI, XML::Twig