本文整理汇总了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;
}