Page 2 of 2

Posted: Mon Jan 01, 2007 12:33 pm
by Christopher
jmut wrote:It is true that it might not be a problem as long as you use same datasource but still....How about using transactions? You sure cannot use more than one db connection instance because you will loose the transaction despide the fact you use same datasource to write to.
Again, there are several combinations. You could have several "db" objects that share the same connection (i.e. it is the connection that is "static" not the instance. You could also have several objects that composite the same result or transaction object. My point is that the design decision is "What do I want only one of?" It may be an instance of a class or it may be a resource identifier or simply common access to the same resource or something else.

And in PHP the question if often "Could more than one object realistically exist?" because the scripts are so short and focused that there just is not the condition where, for example, multiple Models can be created. So my questions are "What needs to be unique?" and "Am I designing for something that can really happen?"

A Singleton is one way to achieve one kind of unique.