laserlight;10925239 wrote:
Originally Posted by amy.damnit
Based on the snippet I provided, if 4 people access the same PHP page and run separate queries against a database, then wouldn't I need 4 separate Database Handlers/Sessions for each person (i.e. Object Variables) versus one "global" Class Variable??
Yes, you would. The reason for the single class member variable is to avoid multiple such objects on the same run of the script, i.e., you only need one database connection for the various queries that will be run for the given user.
So let me repeat all of this to make sure I understand...
1.) A given user only needs one Database Connection per session (assuming the same database is being accessed)?
So, whether Suzy-Q runs 1 or 1,000 queries on SomePage.php, she only needs one database connection?
2.) A Class (Static) Variable is used to ensure #1 happens, so that you don't get 1,000 Instance Variables/Database Connections?
3.) Each time a separate user accesses a given PHP page, the entire PHP page script runs?
So, if 293 users went to SomePage.php, then SomePage.php runs 293 times?
4.) Each separate user needs their own Database Connection?
5.) Even with #4, because of #3, you can "get by" with one Class (Static) Variable.
If 45 people access SomePage.php then SomePage.php runs 45 separate times and each of those 45 separate people gets one Class (Static) Variable for their respective Database Connection?
**NOTE: That last one is hard to believe, especially if we are talking about hundreds of concurrent users or thousands of visitors (e.g. Amazon.com), but if that is what you say then I guess I have to believe it! 🙂
Amy