Skip to content

Commit 558980d

Browse files
committed
Query类增加getSqlLog方法获取sql日志信息
1 parent 6ea7e95 commit 558980d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/db/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ public function connect(array $config = [], $linkNum = 0, $autoConnection = fals
488488
}
489489
} catch (\PDOException $e) {
490490
if ($autoConnection) {
491-
$this->log($e->getMessage(), 'error');
491+
$this->log('[ ERR ] ' . $e->getMessage());
492492
return $this->connect($autoConnection, $linkNum);
493493
} else {
494494
throw $e;
@@ -1840,7 +1840,7 @@ public function log($log)
18401840

18411841
public function getSqlLog()
18421842
{
1843-
return $this->log;
1843+
return self::$log;
18441844
}
18451845

18461846
/**

src/db/Query.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ public function getLastSql()
299299
return $this->connection->getLastSql();
300300
}
301301

302+
/**
303+
* 获取sql记录
304+
* @access public
305+
* @return string
306+
*/
307+
public function getSqlLog()
308+
{
309+
return $this->connection->getSqlLog();
310+
}
311+
302312
/**
303313
* 执行数据库事务
304314
* @access public

0 commit comments

Comments
 (0)