Przeglądaj źródła

Update DB\Pgsql

Visman 3 lat temu
rodzic
commit
38063fe1d3
1 zmienionych plików z 8 dodań i 10 usunięć
  1. 8 10
      app/Core/DB/Pgsql.php

+ 8 - 10
app/Core/DB/Pgsql.php

@@ -491,16 +491,12 @@ class Pgsql
         $size     *= $blockSize ?: 8192;
         $size     *= $blockSize ?: 8192;
 
 
         $other = [];
         $other = [];
-#        $stmt  = $this->db->query("SHOW VARIABLES LIKE 'character\\_set\\_%'");
-#
-#        while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
-#            $other[$row[0]] = $row[1];
-#        }
+        $other['pg_database_size'] = $this->db->query('SELECT pg_size_pretty(pg_database_size(current_database()))')->fetchColumn();
 
 
         return [
         return [
-            'db'      => 'PostgreSQL (PDO) ' . $this->db->getAttribute(PDO::ATTR_SERVER_VERSION) . " : ({$tables})",
-            'records' => $records,
-            'size'    => $size,
+            'db'          => 'PostgreSQL (PDO) v.' . $this->db->getAttribute(PDO::ATTR_SERVER_VERSION) . " : ({$tables})",
+            'records'     => $records,
+            'size'        => $size,
             'server info' => $this->db->getAttribute(PDO::ATTR_SERVER_INFO),
             'server info' => $this->db->getAttribute(PDO::ATTR_SERVER_INFO),
         ] + $other;
         ] + $other;
     }
     }
@@ -521,12 +517,14 @@ class Pgsql
         $stmt   = $this->db->query($query, $vars);
         $stmt   = $this->db->query($query, $vars);
         $result = [];
         $result = [];
         $table  = null;
         $table  = null;
+
         while ($row = $stmt->fetch()) {
         while ($row = $stmt->fetch()) {
             if ($table !== $row['table_name']) {
             if ($table !== $row['table_name']) {
-                $table = $row['table_name'];
-                $tableNoPref = \substr($table, \strlen($this->dbPrefix));
+                $table                = $row['table_name'];
+                $tableNoPref          = \substr($table, \strlen($this->dbPrefix));
                 $result[$tableNoPref] = [];
                 $result[$tableNoPref] = [];
             }
             }
+
             $type = \strtolower($row['data_type']);
             $type = \strtolower($row['data_type']);
             $result[$tableNoPref][$row['column_name']] = $this->types[$type] ?? 's';
             $result[$tableNoPref][$row['column_name']] = $this->types[$type] ?? 's';
         }
         }