Connection类的debug方法改进,增加第二个参数,改进数据库驱动的获取表信息的sql记录

This commit is contained in:
thinkphp
2016-08-08 11:09:44 +08:00
parent f21e6827e1
commit 4e66bf24e6
5 changed files with 67 additions and 26 deletions

View File

@@ -43,9 +43,13 @@ class Sqlite extends Connection
$this->initConnect(true);
list($tableName) = explode(' ', $tableName);
$sql = 'PRAGMA table_info( ' . $tableName . ' )';
$pdo = $this->linkID->query($sql);
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
$info = [];
// 调试开始
$this->debug(true);
$pdo = $this->linkID->query($sql);
// 调试结束
$this->debug(false, $sql);
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
$info = [];
if ($result) {
foreach ($result as $key => $val) {
$val = array_change_key_case($val);
@@ -73,7 +77,11 @@ class Sqlite extends Connection
$sql = "SELECT name FROM sqlite_master WHERE type='table' "
. "UNION ALL SELECT name FROM sqlite_temp_master "
. "WHERE type='table' ORDER BY name";
$pdo = $this->linkID->query($sql);
// 调试开始
$this->debug(true);
$pdo = $this->linkID->query($sql);
// 调试结束
$this->debug(false, $sql);
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
$info = [];
foreach ($result as $key => $val) {
@@ -93,7 +101,8 @@ class Sqlite extends Connection
return [];
}
protected function supportSavepoint(){
protected function supportSavepoint()
{
return true;
}
}