Bitrix Site Manager

CDatabase::Connect

bool
CDatabase::Connect(
 string host,
 string db,
 string login,
 string password
)

The method Connect opens a connection to the database.

Parameters

ParameterDescription
host Database server.
db Database name.
login Login
password Password.

Return Values

Returns true on success or false otherwise.

See Also

Example



<?
if(!($DB->Connect($DBHost, $DBName, $DBLogin, $DBPassword)))
{
    if (file_exists($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/php_interface/dbconn_error.php"))
    {
        include($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/php_interface/dbconn_error.php");
    }
    else
    {
        include($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/dbconn_error.php");
    }
    die();
}
?>