only test read only on postgress
authorAlan <alan@roojs.com>
Wed, 23 Feb 2022 07:44:49 +0000 (15:44 +0800)
committerAlan <alan@roojs.com>
Wed, 23 Feb 2022 07:44:49 +0000 (15:44 +0800)
DB/pgsql.php
HTML/FlexyFramework.php

index 1b32ef8..5a25d4e 100644 (file)
@@ -1019,9 +1019,11 @@ class DB_pgsql extends DB_common
                                     WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid
                                     AND f.attrelid = a.adrelid AND f.attname = '$field_name'
                                     AND $tableWhere AND f.attnum = a.adnum");
-                $row = @pg_fetch_row($result, 0);
-                $num = preg_replace("/'(.*)'::\w+/", "\\1", $row[0]);
-                $flags .= 'default_' . rawurlencode($num) . ' ';
+                if ($result && @pg_numrows($result) > 0 ) {
+                    $row = @pg_fetch_row($result, 0);
+                    $num = preg_replace("/'(.*)'::\w+/", "\\1", $row[0]);
+                    $flags .= 'default_' . rawurlencode($num) . ' ';
+                }
             }
         } else {
             $flags = '';
index b9297b7..d9a243a 100755 (executable)
@@ -915,11 +915,15 @@ RewriteRule ^(.+)$ /web.hpasite/index.local.php [L,NC,E=URL:$1]
                 Please check the value given to HTML_FlexyFramework, or run with debug on!<BR>
                  <BR> ".$err->toString());
         }
-        $res = $err->query("SELECT @@global.read_only as ro");
+        // only applies to mysql...
         
-        $row = is_a($res, 'DB_Error') ? false : $res->fetchRow(DB_FETCHMODE_ASSOC);
-        if (!$row || (!empty($row['ro']) && empty($options['skip-read-only-check']))) {
-            $this->fatalError("Database is configured to be read-only - please check database<BR> ".$err->toString());
+        if (preg_match('/^mysql/', $this->database)) {
+            $res = $err->query("SELECT @@global.read_only as ro");
+            
+            $row = is_a($res, 'DB_Error') ? false : $res->fetchRow(DB_FETCHMODE_ASSOC);
+            if (!$row || (!empty($row['ro']) && empty($options['skip-read-only-check']))) {
+                $this->fatalError("Database is configured to be read-only - please check database<BR> ".$err->toString());
+            }
         }
         // reset dont die!
         $options['dont_die'] = $dd ;