本文整理匯總了PHP中DbConn::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP DbConn::instance方法的具體用法?PHP DbConn::instance怎麽用?PHP DbConn::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DbConn
的用法示例。
在下文中一共展示了DbConn::instance方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: switch
/**
* This function return the current instance for the class, if it's the first
* time that is called it will instance the class
* @return DbConn
*/
public static function &getInstance()
{
if (self::$instance == NULL) {
$db_type = Get::cfg('db_type', function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
switch ($db_type) {
case "mysql":
require_once _base_ . '/db/drivers/docebodb.mysql.php';
self::$instance = new Mysql_DbConn();
self::$instance->debug = Get::cfg('do_debug');
$conn = self::$instance->connect(Get::cfg('db_host'), Get::cfg('db_user'), Get::cfg('db_pass'), Get::cfg('db_name'));
if ($conn) {
self::$connected = true;
}
break;
case "mysqli":
require_once _base_ . '/db/drivers/docebodb.mysqli.php';
self::$instance = new Mysqli_DbConn();
self::$instance->debug = Get::cfg('do_debug');
$conn = self::$instance->connect(Get::cfg('db_host'), Get::cfg('db_user'), Get::cfg('db_pass'), Get::cfg('db_name'));
if ($conn) {
self::$connected = true;
}
break;
}
}
return self::$instance;
}