Ver Mensaje Individual
  #13 (permalink)  
Antiguo 30/08/2010, 15:14
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 PDO y mi clase

En el post arriba del que tienes, tienes un ejemplo del Registry, del de config es simplemente una clase que puede leer desde archivos ini, por ejemplo:
Código PHP:
Ver original
  1. <?php
  2. class Config
  3. {
  4.     private $_config;
  5.     public function __construct($sFile)
  6.     {
  7.         if (!file_exists($sFile)) {
  8.             throw new Exception("Can't find file: $sFile");
  9.         }
  10.        
  11.         $this->_config = parse_ini_file($sFile);
  12.     }
  13.    
  14.     public function getConfig()
  15.     {
  16.         return $this->_config;
  17.     }
  18. }
  19.  
  20. class db {
  21.     private $_username;
  22.     private $_password;
  23.     private $_host;
  24.     private $_db;
  25.    
  26.     public function __construct(Config $config)
  27.     {
  28.         $config_data = $config->getConfig();
  29.         $this->_username = $config_data['username'];
  30.         $this->_password = $config_data['password'];
  31.         $this->_host = $config_data['host'];
  32.         $this->_db = $config_data['db'];
  33.     }
  34. }

Y un .ini:
Código:
username = "foo"
password = "baz"
host = "localhost"
db = "foobarbaz"
Saludos.