本文整理匯總了PHP中Db::_instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Db::_instance方法的具體用法?PHP Db::_instance怎麽用?PHP Db::_instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Db
的用法示例。
在下文中一共展示了Db::_instance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getInstance
public static function getInstance()
{
if (!self::$_instance) {
// If no instance then make one
self::$_instance = new self();
}
return self::$_instance;
}
示例2: getInstance
/**
* 創建db對象
*/
public static function getInstance()
{
if (!is_object(self::$_instance)) {
self::$_instance = new Db();
}
return self::$_instance;
}
示例3: instance
/**
* @return Db
*/
public static function instance()
{
if (is_null(self::$_instance)) {
self::$_instance = self::factry();
}
return self::$_instance;
}
示例4: getInstance
/**
* 取得數據庫類實例
* @static
* @access public
* @return mixed 返回數據庫驅動類
*/
public static function getInstance($db_config = '')
{
if (self::$_instance == null) {
self::$_instance = new Db($db_config);
}
return self::$_instance;
}
示例5: getInstance
public static function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new PDO('mysql:host=localhost;dbname=localization;charset=utf8;"', 'root', 'sera');
}
return self::$_instance;
}
示例6: getInstance
public static function getInstance($which_db = 'model')
{
if (self::$_instance == null) {
self::$_instance = self::_connect($which_db);
}
return self::$_instance;
}
示例7: getInstance
/**
* Статическая функция, которая возвращает
* экземпляр класса или создает новый при
* необходимости
* @return Db
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
示例8: getInstance
/**
* 獲取數據庫單例實例
*
* @return object self
* @author Seven Du <lovevipdsw@vip.qq.com>
**/
public static function getInstance($config = null)
{
if (!self::$_instance instanceof self) {
self::$_instance = new self($config);
}
return self::$_instance;
}
示例9: getInstance
public static function getInstance()
{
if (!self::$_instance instanceof self) {
self::$_instance = new self();
}
return self::$_instance;
}
示例10: getInstance
/**
* Get Db object instance (Singleton)
*
* @return object Db instance
*/
public static function getInstance()
{
if (!isset(self::$_instance)) {
self::$_instance = new MySQL();
}
return self::$_instance;
}
示例11: getInstance
public static function getInstance()
{
if (is_null(self::$_instance)) {
return self::$_instance = new self();
} else {
return self::$_instance;
}
}
示例12: getInstance
public static function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new PDO("mysql:host=localhost;dbname=translations", "root", "");
self::$_instance->query("SET NAMES utf8");
}
return self::$_instance;
}
示例13: conectar
private function conectar()
{
$this->link = "mysql:host={$this->servidor};dbname={$this->base_datos}";
try {
self::$_instance = new PDO($this->link, $this->username, $this->passwd);
} catch (PDOException $e) {
echo "error: " . $e->getMessage();
}
}
示例14: getInstance
public static function getInstance()
{
// If no instance then make one
if (!self::$_instance) {
//echo( "New connection<br>" );
Logger::write("DEBUG", "New connection");
self::$_instance = new self();
}
return self::$_instance;
}
示例15: getInstance
public static function getInstance(array $config)
{
if (empty($config)) {
throw new SixException("請傳入正確的數據庫參數!", 1);
}
$this->_config = array_filter($config);
if (!self::$_instance instanceof self) {
self::$_instance = new self();
}
return self::$_instance;
}