Ver Mensaje Individual
  #23 (permalink)  
Antiguo 09/08/2011, 09:19
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Duda con clase para la DB(singleton).

Cierto, es mejor que la hagas estatica, algo así:
Código PHP:
Ver original
  1. <?php
  2. class Registry
  3. {
  4.     private static $_registry = array();
  5.    
  6.     private function __construct(){}
  7.    
  8.     public static function has($entry)
  9.     {
  10.         return (isset(self::$_registry[$entry]));
  11.     }
  12.    
  13.     public static function set($entry, $value)
  14.     {
  15.         self::$_registry[$entry] = $value;
  16.     }
  17.    
  18.     public static function get($entry)
  19.     {
  20.         if (self::has($entry)) {
  21.             return self::$_registry[$entry];
  22.         } else {
  23.             return null;
  24.         }
  25.     }
  26.    
  27.     public static function clear()
  28.     {
  29.         self::$_registry = array();
  30.     }
  31. }

Saludos.