public static function getInstance() { if (!self::$instance) { self::$instance = new ConnectionFactory(); } return self::$instance; }
/** * @return ConnectionFactory */ public static function getInstance() { if (self::$instance === null) { self::$instance = new self(); } return self::$instance; }
/** * Retorna um objeto da classe ConnectionFactory * @return ConnectionFactory object */ public static function getInstance() { if (!isset(self::$instance)) { $c = __CLASS__; self::$instance = new $c(); } return self::$instance; }
public static function getInstance() { if (!isset(self::$instance)) { try { self::$instance = new PDO('mysql:host=' . ConnectionProperty::getHost() . ';dbname=' . ConnectionProperty::getDatabase() . ';charset=utf8', ConnectionProperty::getUser(), ConnectionProperty::getPassword()); self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); } catch (PDOException $e) { echo $e->getMessage(); } } return self::$instance; }