NW_love/plugins/SqlConn.php
2023-02-03 10:31:07 +08:00

27 lines
679 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* nw_love API head_loader
* @copyright 2022-2023 ZCW and YN. All Rights Reserved.
*/
/** @var string $config */
$SqlHost = $config['SQL']['host'];
$SqlDBname = $config['SQL']['dbname'];
$SqlUsername = $config['SQL']['username'];
$SqlPassword = $config['SQL']['password'];
// 判断数据库的端口
if ($config['SQL']['port'] == 3306 or $config['SQL']['port'] == NULL) {
$SqlPort = 3306;
} else {
$SqlPort = $config['SQL']['port'];
}
// 链接数据库
$SqlConn = new MySQLi($SqlHost,$SqlUsername,$SqlPassword,$SqlDBname,$SqlPort);
// 检查错误
if ($config['WEB']['DeBUG']) {
die('数据库链接失败ErrorCode: '.$SqlConn->connect_error);
}