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

@@ -46,9 +46,13 @@ class Pgsql extends Connection
$this->initConnect(true);
list($tableName) = explode(' ', $tableName);
$sql = 'select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg(\'' . $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,8 +77,12 @@ class Pgsql extends Connection
*/
public function getTables($dbName = '')
{
$sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'";
$pdo = $this->linkID->query($sql);
$sql = "select tablename as Tables_in_test from pg_tables where schemaname ='public'";
// 调试开始
$this->debug(true);
$pdo = $this->linkID->query($sql);
// 调试结束
$this->debug(false, $sql);
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
$info = [];
foreach ($result as $key => $val) {
@@ -94,7 +102,8 @@ class Pgsql extends Connection
return [];
}
protected function supportSavepoint(){
protected function supportSavepoint()
{
return true;
}
}