本文整理汇总了PHP中CDatabase::DoConnect方法的典型用法代码示例。如果您正苦于以下问题:PHP CDatabase::DoConnect方法的具体用法?PHP CDatabase::DoConnect怎么用?PHP CDatabase::DoConnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatabase
的用法示例。
在下文中一共展示了CDatabase::DoConnect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetDBNodeConnection
function GetDBNodeConnection($node_id, $bIgnoreErrors = false, $bCheckStatus = true)
{
global $DB;
if (!array_key_exists($node_id, self::$arNodes)) {
if (CModule::IncludeModule('cluster')) {
self::$arNodes[$node_id] = CClusterDBNode::GetByID($node_id);
} else {
self::$arNodes[$node_id] = false;
}
}
$node =& self::$arNodes[$node_id];
if (is_array($node) && (!$bCheckStatus || $node["ACTIVE"] == "Y" && ($node["STATUS"] == "ONLINE" || $node["STATUS"] == "READY")) && !isset($node["ONHIT_ERROR"])) {
if (!array_key_exists("DB", $node)) {
$node_DB = new CDatabase();
$node_DB->type = $DB->type;
$node_DB->debug = $DB->debug;
$node_DB->DebugToFile = $DB->DebugToFile;
$node_DB->bNodeConnection = true;
$node_DB->node_id = $node_id;
if ($node_DB->Connect($node["DB_HOST"], $node["DB_NAME"], $node["DB_LOGIN"], $node["DB_PASSWORD"])) {
if (defined("DELAY_DB_CONNECT") && DELAY_DB_CONNECT === true) {
if ($node_DB->DoConnect()) {
$node["DB"] = $node_DB;
}
} else {
$node["DB"] = $node_DB;
}
}
}
if (array_key_exists("DB", $node)) {
return $node["DB"];
}
}
if ($bIgnoreErrors) {
return false;
} else {
if (file_exists($_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/dbconn_error.php")) {
include $_SERVER["DOCUMENT_ROOT"] . BX_PERSONAL_ROOT . "/php_interface/dbconn_error.php";
} else {
include $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/dbconn_error.php";
}
die;
}
}
示例2: InitPureDB
function InitPureDB()
{
if (!function_exists('SendError'))
{
function SendError($str)
{
}
}
if (!function_exists('IsModuleInstalled'))
{
function IsModuleInstalled($module)
{
if ($m = trim($module))
return file_exists($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/'.$m);
return false;
}
}
global $DB, $DBType, $DBDebug, $DBDebugToFile, $DBHost, $DBName, $DBLogin, $DBPassword, $DBSQLServerType;
/**
* Defined in dbconn.php
* @var $DBType
* @var $DBDebug
* @var $DBDebugToFile
* @var $DBHost
* @var $DBName
* @var $DBLogin
* @var $DBPassword
*/
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn.php");
if(defined('BX_UTF'))
define('BX_UTF_PCRE_MODIFIER', 'u');
else
define('BX_UTF_PCRE_MODIFIER', '');
include_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/lib/loader.php");
$application = \Bitrix\Main\HttpApplication::getInstance();
$application->initializeBasicKernel();
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/".$DBType."/database.php");
$DB = new CDatabase;
$DB->debug = $DBDebug;
$DB->DebugToFile = $DBDebugToFile;
if(!($DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)) || !($DB->DoConnect()))
{
if(file_exists(($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn_error.php")))
include($fname);
else
include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/dbconn_error.php");
die();
}
if (file_exists($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect.php"))
require_once($fname);
if (file_exists($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect_d7.php"))
require_once($fname);
}
示例3: InitPureDB
function InitPureDB()
{
if (!function_exists('SendError'))
{
function SendError($str)
{
}
}
if (!function_exists('IsModuleInstalled'))
{
function IsModuleInstalled($module)
{
if ($m = trim($module))
return file_exists($_SERVER['DOCUMENT_ROOT'].'/freetrix/modules/'.$m);
return false;
}
}
global $DB;
/**
* Defined in dbconn.php
* @var $DBType
* @var $DBDebug
* @var $DBDebugToFile
* @var $DBHost
* @var $DBName
* @var $DBLogin
* @var $DBPassword
*/
require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/php_interface/dbconn.php");
if(defined('FX_UTF'))
define('FX_UTF_PCRE_MODIFIER', 'u');
else
define('FX_UTF_PCRE_MODIFIER', '');
include_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/lib/loader.php");
$application = \Freetrix\Main\HttpApplication::getInstance();
$application->initializeBasicKernel();
require_once($_SERVER["DOCUMENT_ROOT"]."/freetrix/modules/main/classes/".$DBType."/database.php");
$DB = new CDatabase;
$DB->debug = $DBDebug;
$DB->DebugToFile = $DBDebugToFile;
if(!($DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)) || !($DB->DoConnect()))
{
/* @todo: make universal method/function */
throw new \Exception('Cannont connect to database . Please check settings');
}
}
示例4: InitPureDB
function InitPureDB()
{
if (!function_exists('SendError'))
{
function SendError($str)
{
}
}
global $DB;
/**
* Defined in dbconn.php
* @var $DBType
* @var $DBDebug
* @var $DBDebugToFile
* @var $DBHost
* @var $DBName
* @var $DBLogin
* @var $DBPassword
*/
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn.php");
if(defined('BX_UTF'))
define('BX_UTF_PCRE_MODIFIER', 'u');
else
define('BX_UTF_PCRE_MODIFIER', '');
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/classes/".$DBType."/database.php");
$DB = new CDatabase;
$DB->debug = $DBDebug;
$DB->DebugToFile = $DBDebugToFile;
if(!($DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)) || !($DB->DoConnect()))
{
if(file_exists(($fname = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/dbconn_error.php")))
include($fname);
else
include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/dbconn_error.php");
die();
}
if (file_exists($after = $_SERVER["DOCUMENT_ROOT"]."/bitrix/php_interface/after_connect.php"))
include_once($after);
}
示例5: ForkActions
static function ForkActions($func = false, $args = array())
{
if (!defined("BX_FORK_AGENTS_AND_EVENTS_FUNCTION") || !function_exists(BX_FORK_AGENTS_AND_EVENTS_FUNCTION) || !function_exists("getmypid") || !function_exists("posix_kill")) {
return false;
}
//Avoid to recurse itself
if (defined("BX_FORK_AGENTS_AND_EVENTS_FUNCTION_STARTED")) {
return false;
}
//Register function to execute in forked process
if ($func !== false) {
self::$forkActions[] = array($func, $args);
return true;
}
//There is nothing to do
if (empty(self::$forkActions)) {
return true;
}
//Release session
session_write_close();
$func = BX_FORK_AGENTS_AND_EVENTS_FUNCTION;
$pid = $func();
//Parent just exits.
if ($pid > 0) {
return false;
}
//Fork was successfull let's do seppuku on shutdown
if ($pid == 0) {
register_shutdown_function(create_function('', 'posix_kill(getmypid(), 9);'));
}
//Mark start of execution
// define("BX_FORK_AGENTS_AND_EVENTS_FUNCTION_STARTED", true);
global $DB, $CACHE_MANAGER;
$CACHE_MANAGER = new CCacheManager();
$DBHost = $DB->DBHost;
$DBName = $DB->DBName;
$DBLogin = $DB->DBLogin;
$DBPassword = $DB->DBPassword;
$DB = new CDatabase();
$DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword);
$app = \Bitrix\Main\Application::getInstance();
if ($app != null) {
$con = $app->getConnection();
if ($con != null) {
$con->connect();
}
}
$DB->DoConnect();
$DB->StartUsingMasterOnly();
foreach (self::$forkActions as $action) {
call_user_func_array($action[0], $action[1]);
}
$DB->Disconnect();
$CACHE_MANAGER->_Finalize();
return null;
}