]> git.joonet.de Git - adminer.git/commitdiff
Fix $result visibility
authorJakub Vrana <jakub@vrana.cz>
Tue, 11 Mar 2025 11:53:35 +0000 (12:53 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 11 Mar 2025 11:53:35 +0000 (12:53 +0100)
adminer/drivers/mysql.inc.php
adminer/drivers/oracle.inc.php
adminer/drivers/pgsql.inc.php

index 8e7e9a9f6c42d0cd3c2381e120c431fe26d7ffbc..cde85fe3d0f77b4092bbcac48dac2d565c24e5e3 100644 (file)
@@ -177,10 +177,7 @@ if (!defined('Adminer\DRIVER')) {
                        */
                        function result($query, $field = 0) {
                                $result = $this->query($query);
-                               if (!$result || !$result->num_rows) {
-                                       return false;
-                               }
-                               return mysql_result($result->result, 0, $field);
+                               return ($result ? $result->fetch_column($field) : false);
                        }
                }
 
@@ -210,6 +207,14 @@ if (!defined('Adminer\DRIVER')) {
                                return mysql_fetch_row($this->result);
                        }
 
+                       /** Fetch a single column
+                       * @param int
+                       * @return string or false if there are no rows
+                       */
+                       function fetch_column($field) {
+                               return ($this->num_rows ? mysql_result($this->result, 0, $field) : false);
+                       }
+
                        /** Fetch next field
                        * @return object properties: name, type, orgtable, orgname, charsetnr
                        */
index 7b831025836cc29c8481a5c676f766445d0a02d0..6b9726f92a523c08b9c5a6ff558e71b0bfc641f3 100644 (file)
@@ -75,10 +75,7 @@ if (isset($_GET["oracle"])) {
 
                        function result($query, $field = 0) {
                                $result = $this->query($query);
-                               if (!is_object($result) || !oci_fetch($result->result)) {
-                                       return false;
-                               }
-                               return oci_result($result->result, $field + 1);
+                               return (is_object($result) ? $result->fetch_column($field) : false);
                        }
                }
 
@@ -107,6 +104,10 @@ if (isset($_GET["oracle"])) {
                                return $this->convert(oci_fetch_row($this->result));
                        }
 
+                       function fetch_column($field) {
+                               return (oci_fetch($this->result) ? oci_result($this->result, $field + 1) : false);
+                       }
+
                        function fetch_field() {
                                $column = $this->offset++;
                                $return = new \stdClass;
index e11879375d0e0067ea085c824fee83acc1151388..b601d79f25bf60666f02267a670c9ca05e75d7a0 100644 (file)
@@ -104,10 +104,7 @@ if (isset($_GET["pgsql"])) {
 
                        function result($query, $field = 0) {
                                $result = $this->query($query);
-                               if (!$result || !$result->num_rows) {
-                                       return false;
-                               }
-                               return pg_fetch_result($result->result, 0, $field);
+                               return ($result ? $result->fetch_column($field) : false);
                        }
 
                        function warnings() {
@@ -132,6 +129,10 @@ if (isset($_GET["pgsql"])) {
                                return pg_fetch_row($this->result);
                        }
 
+                       function fetch_column($field) {
+                               return ($this->num_rows ? pg_fetch_result($this->result, 0, $field) : false);
+                       }
+
                        function fetch_field() {
                                $column = $this->offset++;
                                $return = new \stdClass;