|
Posted by Erwin Moller on 12/01/06 14:43
Jerry Stuckle wrote:
> d.adamkiewicz@i7.com.pl wrote:
>> Hello Folks
>>
>> Anybody can show me real world singleton class example?
>> Something that works (is implemented) as part of working solution.
>> Does it make sense to create database handler class that way?
>>
>> Regards
>> Darek
>>
>
> Darek,
>
> I've used them for database classes before. It allows me to have
> multiple classes (representing my business-layer logic) using the same
> instance without worrying about whether the object has been previously
> defined or used.
>
> Because of the transactional nature of web pages, they aren't as useful
> as in other programs. But they still have a use.
>
Jerry,
We once had a 'discussion' about this that ended in a ... well... not too
nice. :-)
So let me try again. (I am not trying to start flaming again, but I am
curious because I am afraid I am missing something.)
My confusion/question:
What is the use of a singleton is when running PHP?
I completely understand (and used) the concept in Java (J2EE), but I fail to
see the advantage of a singleton in PHP, since PHP is executing 'per-page'.
I can see the advantage of PHP connectionpooling (behind the scenes), but
why make a singleton for db-connect?
As far as I understand, you can use the same connection many times on the
same page, so what is the singleton adding to it?
TIA!
Regrads,
Erwin Moller
Navigation:
[Reply to this message]
|