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