Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
January 11, 2006, 1:05 am
rate this thread
I mean, when building my applications, I often need to do several
database actions, and I'm thinking, what's better?
1) Open connection with DB, for instance mySQL, at beginning and close
at the end, so every "unit" in the code knows that THIS IS the
connection, and its opened.
2) Every "unit" in the code opens and closes DB connection
Re: Is it better to open connection with DB at beginning and close at end, or after every "object run"?
Ideally, it should use persistent connections (if the server allows), and
the object shouldn't initiate its connection to the DB unless it's passed a
query (so don't do it when the object is constructed, but when it's actually