- Модуль: security
- Путь к файлу: ~/bitrix/modules/security/classes/mysql/database.php
- Класс: CSecurityDB
- Вызов: CSecurityDB::Init
static function Init($bDoConnect = false)
{
if (is_object(self::$connection))
{
return true;
}
$pool = BitrixMainApplication::getInstance()->getConnectionPool();
$isConnectionExists = $pool->getConnection(static::CONNECTION_NAME) !== null;
if (!$isConnectionExists)
{
$pool->cloneConnection(
$pool::DEFAULT_CONNECTION_NAME,
static::CONNECTION_NAME
);
}
if ($bDoConnect)
{
self::$connection = $pool->getConnection(static::CONNECTION_NAME);
}
else
{
return true;
}
//In case of error just skip it over
if (!is_object(self::$connection))
{
return false;
}
if (
defined("BX_SECURITY_SQL_LOG_BIN")
&& (
BX_SECURITY_SQL_LOG_BIN === false
|| BX_SECURITY_SQL_LOG_BIN === "N"
)
)
{
CSecurityDB::Query("SET sql_log_bin = 0", "Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__."; Line: ".__LINE__);
}
$rs = CSecurityDB::Query("SHOW TABLES LIKE 'b_sec_session'", "Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__."; Line: ".__LINE__);
if (!is_object($rs))
{
return false;
}
$ar = CSecurityDB::Fetch($rs);
if ($ar)
{
return true;
}
if (defined("MYSQL_TABLE_TYPE") && MYSQL_TABLE_TYPE <> '')
{
$rs = CSecurityDB::Query("SET storage_engine = '".MYSQL_TABLE_TYPE."'", "Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__."; Line: ".__LINE__);
if (!is_object($rs))
{
return false;
}
}
$rs = CSecurityDB::Query("CREATE TABLE b_sec_session
(
SESSION_ID VARCHAR(250) NOT NULL,
TIMESTAMP_X TIMESTAMP NOT NULL,
SESSION_DATA LONGTEXT,
PRIMARY KEY(SESSION_ID),
KEY ix_b_sec_session_time (TIMESTAMP_X)
)
", "Module: security; Class: CSecurityDB; Function: Init; File: ".__FILE__."; Line: ".__LINE__);
return is_object($rs);
}