Page 1 of 1
How to store database connection?
Posted: Fri Jun 26, 2009 5:08 am
by jlising
Hello,
How can I store my database connection so that I can avoid connect and disconnect in every page?
Many Thanks!
Jess
Re: How to store database connection?
Posted: Fri Jun 26, 2009 5:34 am
by jayshields
You can't really do that, although you can do things to simulate what you're suggesting.
The easiest solution is to put your database connection code into a PHP file of it's own and require() it on each page. A more complex solution would be to use a front controller which handles rudimentary tasks such as database connections, sessions, templating, etc., this idea is better for larger projects.
Re: How to store database connection?
Posted: Sun Jun 28, 2009 7:04 pm
by jlising
Hi
Someone told me to use serialize() and unserialize() functions to store database connections. I know the syntax of the two but can anyone show me how to use them?
Many Thanks!
Jess