View Single Post
Old 05-18-2009, 04:43 PM   #5 (permalink)
xenon
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Quote:
Originally Posted by Wildhoney View Post
Where is LOCAL defined and why do we have an empty __clone method?
I don't see either where that LOCAL constant was defined...supposedly in another file, which kind of breaks the OO paradigm. Instead, you should have a private member in your class (called $env or such), and a getter/setter method for that. That way, your class will be entirely decoupled from the rest of the application (and you wouldn't need to define a LOCAL constant in all your scripts - not doing so throws a warning).

As for the private __clone method, that's a common thing (I do it myself), and it's good combined with the singleton pattern. Trying to clone the object returned by the getInstance() method will be permitted (thus breaking the singleton rules), as long as you don't define the __clone method as private

I don't agree though with the public connect function. Calling that method several times will only recreate the connection to the DB. You'd probably want to extend the actual PDO class and transform it into a singleton from within your class.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote