Results 1 to 3 of 3
Sep 19, 2012, 16:32 #1
- Join Date
- Oct 2003
- Prescott Valley, Arizona, United States
- 0 Post(s)
- 0 Thread(s)
Connect to DB - each file or from included file?
I'm curious what the general consensus is on creating your database connection? I have a initialize.php type file where I store all the various variables used in multiple places throughout my site (database connection variables and that sort of thing).
Which do people prefer?
1) Create a database connection inside that initialize script so the connection is made at page load, then using that connection variable to run queries against the database on the pages where they are needed.
2) Just use the stored variables but don't actually create a connection until it is needed on each specific script?
And just for the sake of clarity, does it matter if you are using PDO or procedural coding as to your answer?