stavo provando qualcosa del genere, ma č evidente che sto sbagliando qualcosa ....Codice PHP:class DB {
private static $_istance = null;
private $dns = 'mysql:host=localhost;dbname=name'; // mysql
private $user="root";
private $pass="pass";
/* il costruttore č privato */
private function __construct()
{
$this->_istance = new PDO($this->dns, $this->user, $this->pass);
}
public static function getIstance() {
if(self::$_istance == null)
{
$c = __CLASS__;
self::$_istance = new $c;
}
return self::$_istance;
}
}

Rispondi quotando