in reply to DB Connections across scripts from a module

How do you 'invoke' script B? If it is by running the script using exec or system then you can't share the DB connection - it's a different application using different memory.

If you are loading script B using require or some similar technique show us the code you are using that is failing. With a little imagination you should be able to reduce the code to a couple of small sample scripts that demonstrate the issue (by attempting to share a variable for example).

True laziness is hard work
  • Comment on Re: DB Connections across scripts from a module

Replies are listed 'Best First'.
Re^2: DB Connections across scripts from a module
by LinuxUser2008 (Acolyte) on Jun 03, 2010 at 06:38 UTC
    In Script A, i am having a form.. I populate the text fields in the form, and onSubmit of the form, i am invoking Script B.. Script A, will populate the contents of the form using a DBConnection.. When Script B is invoked, will the DBConnection from Script A still exist, can i re-use it?
    Hope, you are clear with the problem..
      Uhm, that looks like the description of a simple Web setup. But one in which scriptA does not invoke scriptB. It's more like:
      1. Browser connects to server.
      2. Browser makes a request to server.
      3. Server calls scriptA.
      4. scriptA finishes.
      5. Server send output of scriptA to browser.
      6. Connection terminates.
      7. User goes off to buy a latte.
      8. User comes back, watches some youtube videos.
      9. User fills in form.
      10. User hits submit.
      11. Browser connects to server.
      12. Browser makes request to server.
      13. Server calls scriptB.
      14. scriptB finishes.
      15. Server sends output of scriptB to browser.
      16. Connection terminates.
      By default, connections used in one script will not be available in another script. But that doesn't mean you cannot use a server framework where connections are shared - but even then, a connection will only be reused if the second request comes quickly enough.