PHP Classes

Not a singleton , just create a static function getInstance i...

Recommend this page to a friend!

      Singleton PDO  >  All threads  >  Not a singleton , just create a...  >  (Un) Subscribe thread alerts  
Subject:Not a singleton , just create a...
Summary:Package rating comment
Messages:2
Author:dori bloodanger
Date:2008-03-14 11:45:14
Update:2008-03-15 14:05:07
 

dori bloodanger rated this package as follows:

Utility: Bad
Consistency: Bad
Documentation: Bad
Examples: Bad

  1. Not a singleton , just create a...   Reply   Report abuse  
Picture of dori bloodanger dori bloodanger - 2008-03-14 11:45:15
Not a singleton , just create a static function getInstance in PDO classe but don't prevent the use of the constructor, or use of connect, this is completly stupid learn true design pattern

  2. Re: Not a singleton , just create a...   Reply   Report abuse  
Picture of Remiya Remiya - 2008-03-15 14:05:07 - In reply to message 1 from dori bloodanger
This should be implemented as a class, not as a function.

If you do not plan to extend the SPDO class as database factory class you can easily discard it. The MyPDO class itself can be made Singleton in order to prevent its usage. Also you can declare it abstract and extend with the SPDO class (if you decide to keep it like this).

However, making a class Singleton has its drawbacks. What if you want to open connections to two different databases at one time, i.e. one for reading and one for writing?

 
For more information send a message to info at phpclasses dot org.