PHP Singleton scope |
|
| Comments (3) |
|
Shmulik in Kefar Habad, Israel 24 months ago |
Hi,
Thanks,
|
|
someone in Hemel Hempstead, United Kingdom 15 months ago |
are you taking the piss? i don't think you should be a programmer. |
|
Poncho in Fremont, California 8 months ago |
Shmulik, Firsts off, that "someone in Hemel" is an idiot and obviously a pathetic loser. I'm no expert on this, but this is how I understand it. When you use a singleton pattern class, let's say for a mysql connection, you do create a resource only once and use it for all the requests only in that page. When calling a lot of the mysql functions, the functions attempt to create a resource with each function call. For example if you have two inserts in the same page, you would create two resources. However, when using the singleton pattern you would create only one resource and reuse that resource for all inserts, deletions, updates, etc.. That is the point of singleton pattern. The singleton pattern resource is open only for that page. The mysql connection closes at the end of that page. If you go to another page and mysql is used, another resource is created. "this instance will be available for me through all pages / users requests. " - This is FALSE. The resource is only for you and only on that page. |
Your Reply
change location - create a profile
Subscribe to this discussion as an RSS feed.
