• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP setup_DB函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中setup_DB函数的典型用法代码示例。如果您正苦于以下问题:PHP setup_DB函数的具体用法?PHP setup_DB怎么用?PHP setup_DB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: setup_validate_php_configuration

require_once $CFG->libdir . '/eventslib.php';
// Events functions
require_once $CFG->libdir . '/grouplib.php';
// Groups functions
require_once $CFG->libdir . '/sessionlib.php';
// All session and cookie related stuff
require_once $CFG->libdir . '/editorlib.php';
// All text editor related functions and classes
require_once $CFG->libdir . '/messagelib.php';
// Messagelib functions
require_once $CFG->libdir . '/modinfolib.php';
// Cached information on course-module instances
// make sure PHP is not severly misconfigured
setup_validate_php_configuration();
// Connect to the database
setup_DB();
// Disable errors for now - needed for installation when debug enabled in config.php
if (isset($CFG->debug)) {
    $originalconfigdebug = $CFG->debug;
    unset($CFG->debug);
} else {
    $originalconfigdebug = -1;
}
// Load up any configuration from the config table
initialise_cfg();
// Verify upgrade is not running unless we are in a script that needs to execute in any case
if (!defined('NO_UPGRADE_CHECK') and isset($CFG->upgraderunning)) {
    if ($CFG->upgraderunning < time()) {
        unset_config('upgraderunning');
    } else {
        print_error('upgraderunning');
开发者ID:hatone,项目名称:moodle,代码行数:31,代码来源:setup.php


示例2: setup_ExternalDB

 /**
  * Sets up global $DB moodle_database instance
  *
  * @global stdClass $CFG The global configuration instance.
  * @see config.php
  * @see config-dist.php
  * @global stdClass $DB The global moodle_database instance.
  * @return void|bool Returns true when finished setting up $DB. Returns void when $DB has already been set.
  */
 function setup_ExternalDB()
 {
     global $CFG, $DB, $remotedb;
     // Use a custom $remotedb (and not current system's $DB) if set - code sourced from configurable
     // Reports plugin.
     $remotedbhost = get_config('report_myfeedback', 'dbhost');
     $remotedbname = get_config('report_myfeedback', 'dbname');
     $remotedbuser = get_config('report_myfeedback', 'dbuser');
     $remotedbpass = get_config('report_myfeedback', 'dbpass');
     if (empty($remotedbhost) or empty($remotedbname) or empty($remotedbuser)) {
         $remotedb = $DB;
         setup_DB();
     } else {
         //
         if (!isset($CFG->dblibrary)) {
             $CFG->dblibrary = 'native';
             // use new drivers instead of the old adodb driver names
             switch ($CFG->dbtype) {
                 case 'postgres7':
                     $CFG->dbtype = 'pgsql';
                     break;
                 case 'mssql_n':
                     $CFG->dbtype = 'mssql';
                     break;
                 case 'oci8po':
                     $CFG->dbtype = 'oci';
                     break;
                 case 'mysql':
                     $CFG->dbtype = 'mysqli';
                     break;
             }
         }
         if (!isset($CFG->dboptions)) {
             $CFG->dboptions = array();
         }
         if (isset($CFG->dbpersist)) {
             $CFG->dboptions['dbpersist'] = $CFG->dbpersist;
         }
         if (!($remotedb = moodle_database::get_driver_instance($CFG->dbtype, $CFG->dblibrary))) {
             throw new dml_exception('dbdriverproblem', "Unknown driver {$CFG->dblibrary}/{$CFG->dbtype}");
         }
         try {
             $remotedb->connect($remotedbhost, $remotedbuser, $remotedbpass, $remotedbname, $CFG->prefix, $CFG->dboptions);
         } catch (moodle_exception $e) {
             if (empty($CFG->noemailever) and !empty($CFG->emailconnectionerrorsto)) {
                 $body = "Connection error: " . $CFG->wwwroot . "\n\nInfo:" . "\n\tError code: " . $e->errorcode . "\n\tDebug info: " . $e->debuginfo . "\n\tServer: " . $_SERVER['SERVER_NAME'] . " (" . $_SERVER['SERVER_ADDR'] . ")";
                 if (file_exists($CFG->dataroot . '/emailcount')) {
                     $fp = @fopen($CFG->dataroot . '/emailcount', 'r');
                     $content = @fread($fp, 24);
                     @fclose($fp);
                     if (time() - (int) $content > 600) {
                         //email directly rather than using messaging
                         @mail($CFG->emailconnectionerrorsto, 'WARNING: Database connection error: ' . $CFG->wwwroot, $body);
                         $fp = @fopen($CFG->dataroot . '/emailcount', 'w');
                         @fwrite($fp, time());
                     }
                 } else {
                     //email directly rather than using messaging
                     @mail($CFG->emailconnectionerrorsto, 'WARNING: Database connection error: ' . $CFG->wwwroot, $body);
                     $fp = @fopen($CFG->dataroot . '/emailcount', 'w');
                     @fwrite($fp, time());
                 }
             }
             // rethrow the exception
             throw $e;
         }
         $CFG->dbfamily = $remotedb->get_dbfamily();
         // TODO: BC only for now
         return true;
     }
     return false;
 }
开发者ID:ninelanterns,项目名称:moodle-report_myfeedback,代码行数:81,代码来源:lib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP setup_and_print_groups函数代码示例发布时间:2022-05-15
下一篇:
PHP setupServerVariables函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap