logo       
Google Custom Search
    AddThis Social Bookmark Button

CGI::App::DBH or Ima::DBI: msg#00086

Subject: CGI::App::DBH or Ima::DBI
Hello,

CGI::App::Session seemed like such a good idea, I thought I'd see what
would it would take to do the same thing for database handle management.
Happily, a wheel rolled across my path before I re-invented another.

Has anyone used Ima::DBI for database handle management with CGI::App? I
understand it's used for this as part of the popular Class::DBI
framework.

Based on the documentation, here's my understanding of how basic
integration could happen with a CGI::App sub-class:  

        package Web::App;
        use base qw(CGI::Application Ima::DBI);
        
        sub cgiapp_init {
                my $self = shift;
        
                if (my $args = $self->param('dbi_connect_args') ) {
                        Web::App->set_db('h', @$args);
                }
        }
        
        
        
        sub my_run_mode {
                my $self = shift;
                my $dbh = $self->db_h;
        }

####################

 From its documentation, here are some of the reasons why this could be
a good idea to manage your database connections:


 - Holds off opening a database connection until necessary. 

 - Encapsulation of DBI's cache system
 
 - Sharing of database and sql information amongst inherited classes
 
 - Guarantees one connection per program.

You can read the full documentation here:
http://search.cpan.org/perldoc?Ima::DBI

        Mark


-- 
http://mark.stosberg.com/ 


---------------------------------------------------------------------
Web Archive:  
http://www.mail-archive.com/cgiapp-svx1JCNWaqPWzzAP45jFb16hYfS7NtTn@xxxxxxxxxxxxxxxx/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: 
cgiapp-unsubscribe-svx1JCNWaqPWzzAP45jFb16hYfS7NtTn@xxxxxxxxxxxxxxxx
For additional commands, e-mail: 
cgiapp-help-svx1JCNWaqPWzzAP45jFb16hYfS7NtTn@xxxxxxxxxxxxxxxx





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>