/** * 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; }