Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

CGI::App::Plugin::DBH + variable names

by Anonymous Monk
on Aug 11, 2009 at 09:10 UTC ( #787538=perlquestion: print w/replies, xml ) Need Help??

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

In Cgiapp_init I have several DBs defined like
$self->dbh_config('Server1', [ $self->cfg('dsn'), $self->cfg('dbuser'), $self->cfg('dbpass') ] );
when I try
$dbh = $self->dbh($dbName);
where $dbName is 'Server1', it shows the error
must call dbh_config() before calling dbh().
How can I use a variable here to determine databases?

Replies are listed 'Best First'.
Re: CGI::App::Plugin::DBH + variable names
by Anonymous Monk on Aug 11, 2009 at 09:29 UTC
    Call dbh_config()?
      but when I used
      <c>$dbh = $self->dbh('Server1') if ( uc($dbName) eq 'Server1' );<c>
      It works, I don't see the docs use dbh_config in the examples for this.
        ??

        1. Module is CGI::Application::Plugin::DBH , not CGI::App::Plugin::DBH
        2. It works, I don't see the docs use dbh_config in the examples for this.

          Look at CGI::Application::Plugin::DBH

        That code 'works' in that it doesn't do anything since uc($dbName) eq 'Server1' is always false.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://787538]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2020-02-24 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (104 votes). Check out past polls.

    Notices?