本文整理匯總了PHP中Database::_instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Database::_instance方法的具體用法?PHP Database::_instance怎麽用?PHP Database::_instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Database
的用法示例。
在下文中一共展示了Database::_instance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInstance
public static function getInstance()
{
if (!self::$_instance instanceof Database) {
self::$_instance = new Database();
}
return self::$_instance;
}
示例2: instance
/**
* If an instance of this class has been not been instantiated quite yet, this
* function will create, cache and return the instance. If the instance of
* this class has already been instantiated and cached, the cached version of
* this class instantiation will be returned. Thus, adhering to the rules of
* singleton's.
*
* @return Database The singleton instance of this class. Only ever
* instantiated but one time.
*/
public static function instance()
{
if (!self::$_instance instanceof self) {
self::$_instance = new self();
}
return self::$_instance;
}
示例3: getInstance
public static function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new Database();
}
return self::$_instance;
}
示例4: singleton
public static function singleton()
{
if (!is_object(self::$_instance)) {
self::$_instance = new Database();
}
return self::$_instance;
}
示例5: getInstance
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new Database();
}
return self::$_instance;
}
示例6: getInstance
/**
* Setup the instance (singleton)
*
* @param $config array
* @return Database
*/
public static function getInstance($config = '')
{
if (!self::$_instance instanceof self) {
self::$_instance = new self($config);
}
return self::$_instance;
}
示例7: getInstance
public static function getInstance()
{
if (!self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
示例8: getInstance
/**
* 獲得數據庫連接實例對象
*/
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new self();
}
//echo '輸出實例';
return self::$_instance;
}
示例9: start
/**
* Instantiates the singleton. Checks to make sure there is no instance
* already instantiated by looking at the static property $_instance. If
* it doesn't exist, created it. Otherwise return the handle to this
* resource.
*
* Acts as the constructor for this class.
*
* @param $dbLoc Location of the MySQL database.
* @param $dbName Name of the database being used.
* @param $dbUser Username with access to database.
* @param $dbPass Password for the database user.
* @return Resource handle
*/
public static function start($dbLoc, $dbName, $dbUser, $dbPass)
{
if (!isset(self::$_instance)) {
$c = __CLASS__;
self::$_instance = new $c($dbLoc, $dbName, $dbUser, $dbPass);
}
return self::$_instance;
}
示例10: getInstance
static function getInstance()
{
/*Creates an instance of this object if none exists and returns it.*/
if (self::$_instance === null) {
self::$_instance = new Database();
}
return self::$_instance;
}
示例11: getInstance
public static function getInstance()
{
if (self::$_instance === null) {
$settings = Settings::getInstance();
self::$_instance = new self($settings->db_host(), $settings->db_name(), $settings->db_user(), $settings->db_pass());
}
return self::$_instance;
}
示例12: getInstance
static function getInstance()
{
if (!self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
//als er al een instantie van de database classe is aangemaakt, dan wordt deze instantie zelf teruggeven (zodat er maar 1 databaseconnectie is).
}
示例13: getInstance
/**
* @desc get an instance of the Database
* @params none
* @return Instance
*/
public static function getInstance()
{
if (!self::$_instance) {
// If no instance then make one
self::$_instance = new self();
}
return self::$_instance;
}
示例14: getInstance
static function getInstance()
{
/*Creates an instance of this object if none exists and returns it.*/
if (!self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
示例15: getInstance
public function getInstance()
{
if (!isset(self::$_instance)) {
// :: wywoluje metody klas bez tworzenia instancji obiektow (statyczne wywolanie metody)
self::$_instance = new Database();
// wywolujemy instance i przypisujemy
}
return self::$_instance;
}