Hello,
How can I store my database connection so that I can avoid connect and disconnect in every page?
Many Thanks!
Jess
How to store database connection?
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Re: How to store database connection?
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.
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.
- jlising
- Forum Commoner
- Posts: 33
- Joined: Mon Mar 19, 2007 1:48 am
- Location: Pampanga, Philippines
- Contact:
Re: How to store database connection?
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
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