Beispiel #1
0
 /**
  * Instantiator static method
  * As of PHP 5.3.0, PHP implements a feature called late static bindings which
  * can be used to reference the called class in a context of static inheritance.
  * @return MySQLi
  */
 public static function getInstance()
 {
     if (!is_object(self::$db)) {
         self::$db = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
     }
     return self::$db;
 }
 public static function getDBO()
 {
     if (self::$db == null) {
         self::$db = new DataBase(Config::DB_HOST, Config::DB_USER, Config::DB_PASSWORD, Config::DB_NAME);
     }
     return self::$db;
 }
Beispiel #3
0
 public static function getDB()
 {
     if (self::$db == null) {
         self::$db = new DataBase();
     }
     return self::$db;
 }
Beispiel #4
0
 public static function getDB()
 {
     if (self::$db == null) {
         self::$db = new DataBase(Config::DB_HOST, Config::DB_USER, Config::DB_PASSWORD, Config::DB_NAME, Config::DB_PREFIX, Config::DB_CHARSET, Config::DB_LOCALE);
     }
     return self::$db;
 }
Beispiel #5
0
 public static function init($dbSettings = null)
 {
     if (!self::$db) {
         self::$db = new DataBase($dbSettings);
     }
     return self::$db;
 }
Beispiel #6
0
 public static function getDB()
 {
     // получить экземпляр данного класса
     if (self::$db == null) {
         self::$db = new DataBase();
     }
     // если экземпляр данного класса  не создан
     return self::$db;
     // возвращаем экземпляр данного класса
 }
 public static function getInstance($dsn, $user, $password)
 {
     self::$db = new DataBase($dsn, $user, $password);
     return self::$db;
 }
Beispiel #8
0
 public static function _connect()
 {
     if (!self::$db) {
         self::$db = new PDO('mysql:host=' . Config::get('DB_HOST') . ';dbname=' . Config::get('DB_DATABASE') . ';charset=' . Config::get('DB_CHARSET'), Config::get('DB_USER'), Config::get('DB_PASSWORD'));
     }
 }