terça-feira, 16 de outubro de 2007

PHP ADVANCED :: The Singleton Design Pattern

Design Patterns , usually the GOF (gang of four) technics , are used to solve current problems on software modelling , generally on software engineering cases.
On this article i´ll tell you how to use Singleton Patterns on PHP, on current version PHP5.
This patterns is used when you can use just one single instance of the class you declared, and with it have an active instance without losing the link resource.
An example very useful is what happens on database connections , where , with just one instance you are able to make to rest of operations you need to.
The main properties to work on Singleton with PHP5 , are the private and static properties.
Understand his use are extremly important to build a good Singleton class code.
On the example right next , i´ll will build a simple class to use mysql and msqli according the project settings.

.... this article is beeing written, please stand by

Sem comentários: