Qiang has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am new to C::A and Class::DBI. I have two questions during the learning process.

1. In my C::A script, I have

    $self->mode_param( path_info=> 1 );
then i will request http://localhost/movie/945
where "movie" will be the run mode because of mode_param, but how do i get the 945? do i need to manually parse path_info ?

2. I am trying to use Class::DBI::Loader. currently what i have is (simplified)

sub cgiapp_init {
    my $self = shift;
    my $loader = Class::DBI::Loader->new(
                     dsn => $self->config_param('database.data_source'),
                     options  => { RaiseError => 1, PrintError => 1},
                     namespace     => "ToRest",
                     relationships => 1,
    );
    if ( $loader ) {
        $self->{_To_Rest_Loader} = $loader;
    } else {
        $self->log->debug("dbi loader failed");
    }
}
I know I would need to create a few table classes in Class::DBI way. but i don't need it with Class::DBI::Loader as it does for me. but i felt a bit clumsy to have the $loader saved as $self->{_To_Rest_Loader}

is there a better way to do it?

  • Comment on questions on CGI::Application, Class::DBI::Loader