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


PHP DBInit函数代码示例

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


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

示例1: EveDBInit

function EveDBInit()
{
    // force register_globals=off
    // force register_globals = off
    if (!defined('_PNINSTALLVER') && ini_get('register_globals')) {
        foreach ($GLOBALS as $s_variable_name => $m_variable_value) {
            if (!in_array($s_variable_name, array('GLOBALS', 'argv', 'argc', '_FILES', '_COOKIE', '_POST', '_GET', '_SERVER', '_ENV', '_SESSION', '_REQUEST', 's_variable_name', 'm_variable_value'))) {
                unset($GLOBALS[$s_variable_name]);
            }
        }
        unset($GLOBALS['s_variable_name']);
        unset($GLOBALS['m_variable_value']);
    }
    // proper error_repoting
    // E_ALL for development
    // error_reporting(E_ALL);
    // without warnings and notices for release
    //error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
    //fix solution from i420bdawg
    if (phpversion() >= '5.3.0') {
        error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING);
    } else {
        error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_WARNING);
    }
    // Hack for some weird PHP systems that should have the
    // LC_* constants defined, but don't
    if (!defined('LC_TIME')) {
        define('LC_TIME', 'LC_TIME');
    }
    // Initialise and load configuration
    $dbconfig = array();
    $dbdebug = array();
    include_once 'eveconfig/dbconfig.php';
    $GLOBALS['dbconfig'] = $dbconfig;
    $GLOBALS['dbdebug'] = $dbdebug;
    //echo '<pre>';print_r($GLOBALS);echo '</pre>';exit;
    // Connect to database
    if (!DBInit()) {
        die('Database initialisation failed');
    }
    if (!defined('TBL_PREFIX')) {
        define('TBL_PREFIX', DBGetPrefix());
    }
    return true;
}
开发者ID:orbitroom,项目名称:EVE-Online-POS-Tracker,代码行数:45,代码来源:dbfunctions.php

示例2: Ajax_CheckDB

function Ajax_CheckDB()
{
    global $eve, $eveRender, $stoppage;
    $host = $eve->VarCleanFromInput('dbhost');
    $user = $eve->VarCleanFromInput('dbuname');
    $pass = $eve->VarCleanFromInput('dbpass');
    $db = $eve->VarCleanFromInput('dbname');
    if (empty($host)) {
        $host = 'localhost';
    }
    $dbok = false;
    $server = false;
    $goforit = false;
    include_once 'includes/dbfunctions.php';
    $GLOBALS['dbconfig']['dbtype'] = 'mysql';
    $GLOBALS['dbconfig']['dbhost'] = $host;
    $GLOBALS['dbconfig']['dbname'] = $db;
    $GLOBALS['dbconfig']['dbuname'] = $user;
    $GLOBALS['dbconfig']['dbpass'] = $pass;
    $GLOBALS['dbconfig']['pconnect'] = 0;
    $GLOBALS['dbconfig']['encoded'] = 0;
    $GLOBALS['dbconfig']['debug'] = 0;
    $GLOBALS['dbdebug']['debug_sql'] = 0;
    $answer = '';
    if (empty($user)) {
        return 'No database username';
    }
    if (!DBInit()) {
        $mysqlerror = 'Database Failure!';
        //$dbconn->ErrorMsg();
        $server = false;
        $selectdb = false;
        $stoppage = true;
    } else {
        $server = true;
        if (!($dbconn =& DBGetConn(true))) {
            $answer .= 'Connection Failed!';
            $stoppage = true;
        } else {
            $selectdb = $dbconn->SelectDB($db);
            if (!$selectdb) {
                $mysqlerror = 'Unknown Database';
                $stoppage = true;
            }
            if (!$stoppage) {
                $result = $dbconn->Execute('SELECT VERSION() AS version');
                if ($dbconn->ErrorNo() != 0) {
                    $selectdb = true;
                    $mysqlerror = $dbconn->ErrorMsg();
                    $stoppage = true;
                } else {
                    list($version) = $result->fields;
                }
            }
        }
        if (!$stoppage) {
            $goforit = true;
        }
    }
    if ($goforit) {
        $answer .= 'DATABASE OK - Version: ' . $version . ' - Hit the Write button to save the configuration.';
    } else {
        $answer .= $mysqlerror;
    }
    return $answer;
}
开发者ID:Covert-Inferno,项目名称:pos-tracker-eve,代码行数:66,代码来源:install.php

示例3: require_once

// include required files

require_once(USERPANEL_LIB_DIR.'/checkdirs.php');
require_once(LIB_DIR.'/config.php');

// Initialize database
$_DBTYPE = $CONFIG['database']['type'];
$_DBHOST = $CONFIG['database']['host'];
$_DBUSER = $CONFIG['database']['user'];
$_DBPASS = $CONFIG['database']['password'];
$_DBNAME = $CONFIG['database']['database'];

require_once(LIB_DIR.'/LMSDB.php');

$DB = DBInit($_DBTYPE, $_DBHOST, $_DBUSER, $_DBPASS, $_DBNAME);

if (!$DB) die;

// Initialize templates engine (must be before locale settings)

require_once(LIB_DIR.'/Smarty/Smarty.class.php');

$SMARTY = new Smarty;

// test for proper version of Smarty

if (constant('Smarty::SMARTY_VERSION'))
	$ver_chunks = preg_split('/[- ]/', Smarty::SMARTY_VERSION);
else
	$ver_chunks = NULL;
开发者ID:rzt,项目名称:lms,代码行数:30,代码来源:index.php

示例4: DBInit

 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 *  USA.
 *
 *  $Id$
 */
$_MAILDBTYPE = $CONFIG['database']['mail_db_type'];
$_MAILDBHOST = $CONFIG['database']['mail_db_host'];
$_MAILDBUSER = $CONFIG['database']['mail_db_user'];
$_MAILDBPASS = $CONFIG['database']['mail_db_password'];
$_MAILDBNAME = $CONFIG['database']['mail_db_database'];
// Initialize mail database
$DB_MAIL = DBInit($_MAILDBTYPE, $_MAILDBHOST, $_MAILDBUSER, $_MAILDBPASS, $_MAILDBNAME);
if (defined('USERPANEL_SETUPMODE')) {
    function module_setup()
    {
        global $SMARTY, $LMS;
        $SMARTY->assign('mail_limit', $LMS->CONFIG['userpanel']['mail_limit']);
        $SMARTY->assign('mail_allowed_domains', $LMS->CONFIG['userpanel']['mail_allowed_domains']);
        $SMARTY->display('module:accounts:setup.html');
    }
    function module_submit_setup()
    {
        global $DB;
        $DB->Execute('UPDATE uiconfig SET value = ? WHERE section = \'userpanel\' AND var = \'mail_limit\'', array($_POST['mail_limit']));
        $DB->Execute('UPDATE uiconfig SET value = ? WHERE section = \'userpanel\' AND var = \'mail_allowed_domains\'', array($_POST['mail_allowed_domains']));
        header('Location: ?m=userpanel&module=accounts');
    }
开发者ID:Kliwer,项目名称:lms,代码行数:31,代码来源:functions.php


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