Exemplo n.º 1
0
 public static function getConnection()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Mysql(false);
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new Mysql();
     }
     return self::$instance;
 }
Exemplo n.º 3
0
 public static function getInstance($dbHost)
 {
     if (!Mysql::$instance) {
         Mysql::$instance = new Mysql($dbHost);
     }
     return Mysql::$instance;
 }
Exemplo n.º 4
0
 static function getInstance($dbHost, $dbName, $dbUser, $dbPass) { 
     if(!Mysql::$instance) { 
         Mysql::$instance = new Mysql($dbHost, $dbName, $dbUser, $dbPass); 
     } 
     return Mysql::$instance; 
 } 
Exemplo n.º 5
0
 /**
  * Return a singleton instance
  *
  * @param null $config
  *
  * @return Mysql Singleton Reference
  * @throws MySQLException
  * @throws \Exception
  */
 public static function get_instance($config = null)
 {
     try {
         if (is_null(self::$instance)) {
             self::$instance = new Mysql($config);
         }
     } catch (MySQLException $e) {
         throw $e;
     }
     return self::$instance;
 }
Exemplo n.º 6
0
 public function disconnect()
 {
     if ($this->_mysql_link) {
         mysql_close($this->_mysql_link);
         $this->_mysql_link = null;
     }
     self::$instance = null;
 }
Exemplo n.º 7
0
 public static function getInstance($id)
 {
     if (!$id) {
         foreach (Model::getConnectionsData() as $k => $v) {
             if ($v['type_db'] == "mysql") {
                 $id = $k;
                 break;
             }
         }
     }
     Debug::log("getInstance Mysql.", __LINE__, __FUNCTION__, __CLASS__, __FILE__);
     if (!isset(self::$instance) || !is_object(self::$instance)) {
         $class = __CLASS__;
         self::$instance = new $class($id);
     }
     if (!isset(self::$connection[$id])) {
         self::$instance->newConnection($id);
     }
     return self::$instance;
 }
Exemplo n.º 8
0
 /** static public function get_instance
  *		Returns the singleton instance
  *		of the MySQL Object as a reference
  *
  * @param array optional configuration array
  * @action optionally creates the instance
  * @return MySQL Object reference
  */
 public static function get_instance($config = null)
 {
     try {
         if (is_null(self::$instance)) {
             self::$instance = new Mysql($config);
         }
         self::$instance->test_connection();
         self::$instance->_log(__METHOD__ . ' --------------------------------------');
     } catch (MySQLException $e) {
         throw $e;
     }
     return self::$instance;
 }