/** * Get singelton instance * * @return MySQL */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
public static function getInstance($host = '', $name = '', $pwd = '', $dBase = '') { if (FALSE == self::$_instance instanceof self) { self::$_instance = new self($host, $name, $pwd, $dBase); } return self::$_instance; }
/** * Создаёт, либо возвращает единственный экземпляр MyQSL * * @param string $server * @param string $user * @param string $password */ public static function &creator($server, $user, $password) { if (self::$_instance == NULL) { self::$_instance = new MySQL($server, $user, $password); } return self::$_instance; }
static function GetInstance($host, $user, $password, $database) { if (self::$_instance == null || self::$mysqli != null) { self::$_instance = new MySQL(); self::$mysqli = new mysqli($host, $user, $password, $database); if (mysqli_connect_errno()) { printf("数据库连接失败!:%s\n", mysqli_connect_error()); } } return self::$_instance; }
/** * Singleton accessor to the database instance * -- change this to use a md5 on the $params to allow for multiple single instances */ public static function getInstance($params = NULL) { if (self::$_instance == NULL) { self::$_instance = new MySQL($params); } return self::$_instance; }