Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: DB Connection using CGI::Application

by sundialsvc4 (Abbot)
on Apr 24, 2013 at 19:27 UTC ( #1030493=note: print w/ replies, xml ) Need Help??


in reply to DB Connection using CGI::Application

If you are trying to pass a database connection-handle as a param(), then I would say .. “fuhgeddaboudit!.”   You’re barking up the wrong tree .. the intended solution is actually much simpler(!) than you are making it out to be.

Pause for a moment and consider how CGIApp actually works.   (See also http://cgi-app.org/index.cgi?OrderOfOperations.)

Your CGI application comes into existence to handle one request ... then, it dies.   The sequence of operations, during the lifetime of that one-and-only request, includes the following method calls:

  1. cgiapp_init()
  2. setup()
  3. your request handler, such as 'one' or 'two'
Therefore ... the object exists for the entire time!

Each of these methods occur within a single object, so you actually are free to instantiate any necessary database connection-handles at any point that suits you.   The only thing to bear in mind, from a program-design point of view, is that each of these are method calls, to a single (albeit short-lived...) object, which occur in a definite sequence.

Literally...

  • The CGI process starts.   The object is instantiated.
  • The method-calls occur in the stated sequence.
  • The object coughs-up its output .. then the entire process dies.   (Hey.. life is short... sux.)

I cordially suggest that you should now spend a bit of time at http://www.cgi-app.org.   Read it “entirely, thoughtfully, and carefully.”   Trust me ... the proverbial “little light” will come on.   :-)


Comment on Re: DB Connection using CGI::Application
Re^2: DB Connection using CGI::Application
by Anonymous Monk on Apr 24, 2013 at 19:34 UTC
    I will do that, can I get back to you?
Re^2: DB Connection using CGI::Application
by Anonymous Monk on Apr 25, 2013 at 03:43 UTC

    If you are trying to pass a database connection-handle as a param(), then I would say .. “fuhgeddaboudit!.”

    Typical sundialsvc4 , didn't read the material he advocates reading

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-12-25 06:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls