当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPWS_DB::getDbName方法代码示例

本文整理汇总了PHP中PHPWS_DB::getDbName方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::getDbName方法的具体用法?PHP PHPWS_DB::getDbName怎么用?PHP PHPWS_DB::getDbName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPWS_DB的用法示例。


在下文中一共展示了PHPWS_DB::getDbName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadDB

 /**
  * Loads a connection
  *
  * @param string $dsn
  * @param string $tbl_prefix
  * @param boolean $force_reconnect
  * @param boolean $show_error
  * @return boolean
  */
 public static function loadDB($dsn = null, $tbl_prefix = null, $force_reconnect = false, $show_error = true)
 {
     if (!isset($dsn)) {
         if (!defined('PHPWS_DSN')) {
             exit(_('Cannot load database. DSN not defined.'));
         }
         $dsn = PHPWS_DSN;
         if (defined('PHPWS_TABLE_PREFIX')) {
             $tbl_prefix = PHPWS_TABLE_PREFIX;
         }
     }
     /**
      * if $dsn is already set and force_reconnect is false, don't bother on a reconnect
      */
     if (isset($GLOBALS['PHPWS_DB']['dsn']) && $GLOBALS['PHPWS_DB']['dsn'] == $dsn && !$force_reconnect) {
         return;
     }
     if (isset($GLOBALS['PHPWS_DB']['connection'])) {
         $GLOBALS['PHPWS_DB']['connection']->disconnect();
     }
     $dbname = PHPWS_DB::getDbName($dsn);
     $pear_db = new MDB2();
     $connect = $pear_db->connect($dsn, array('persistent' => false));
     if (PHPWS_Error::isError($connect)) {
         if (CLEAR_DSN) {
             $connect->userinfo = str_replace($dsn, '-- DSN removed --', $connect->userinfo);
         }
         PHPWS_Error::log($connect);
         if ($show_error) {
             PHPWS_Core::errorPage();
         } else {
             return $connect;
         }
     }
     PHPWS_DB::logDB(sprintf(_('Connected to database "%s"'), $dbname));
     // Load the factory files
     $type = $connect->dbsyntax;
     $result = PHPWS_Core::initCoreClass('DB/' . $type . '.php');
     if ($result == false) {
         PHPWS_DB::logDB(_('Failed to connect.'));
         PHPWS_Error::log(PHPWS_FILE_NOT_FOUND, 'core', 'PHPWS_DB::loadDB', PHPWS_SOURCE_DIR . 'core/class/DB/' . $type . '.php');
         PHPWS_Core::errorPage();
     }
     $class_name = $type . '_PHPWS_SQL';
     $dblib = new $class_name();
     if (!empty($dblib->portability)) {
         $connect->setOption('portability', $dblib->portability);
     }
     $connect->setOption('seqcol_name', 'id');
     $GLOBALS['PHPWS_DB']['lib'] = $dblib;
     $GLOBALS['PHPWS_DB']['dsn'] = $dsn;
     $GLOBALS['PHPWS_DB']['connection'] = $connect;
     $GLOBALS['PHPWS_DB']['tbl_prefix'] = $tbl_prefix;
     $GLOBALS['PHPWS_DB']['type'] = $type;
     return true;
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:65,代码来源:PHPWS_DB.php


注:本文中的PHPWS_DB::getDbName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。