mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
记录数据库连接时间
This commit is contained in:
@@ -13,7 +13,6 @@ namespace think\db;
|
|||||||
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use PDOStatement;
|
use PDOStatement;
|
||||||
use think\App;
|
|
||||||
use think\Collection;
|
use think\Collection;
|
||||||
use think\Db;
|
use think\Db;
|
||||||
use think\db\exception\BindParamException;
|
use think\db\exception\BindParamException;
|
||||||
@@ -274,9 +273,14 @@ abstract class Connection
|
|||||||
if (empty($config['dsn'])) {
|
if (empty($config['dsn'])) {
|
||||||
$config['dsn'] = $this->parseDsn($config);
|
$config['dsn'] = $this->parseDsn($config);
|
||||||
}
|
}
|
||||||
|
if ($config['debug']) {
|
||||||
|
$startTime = microtime(true);
|
||||||
|
}
|
||||||
$this->links[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $params);
|
$this->links[$linkNum] = new PDO($config['dsn'], $config['username'], $config['password'], $params);
|
||||||
|
if ($config['debug']) {
|
||||||
// 记录数据库连接信息
|
// 记录数据库连接信息
|
||||||
App::$debug && Log::record('[ DB ] CONNECT: ' . $config['dsn'], 'info');
|
Log::record('[ DB ] CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn'], 'sql');
|
||||||
|
}
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
if ($autoConnection) {
|
if ($autoConnection) {
|
||||||
Log::record($e->getMessage(), 'error');
|
Log::record($e->getMessage(), 'error');
|
||||||
|
|||||||
Reference in New Issue
Block a user