]> git.joonet.de Git - adminer.git/commitdiff
MongoDB: Display error when selecting wrong table
authorJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 15:37:42 +0000 (16:37 +0100)
committerJakub Vrana <jakub@vrana.cz>
Tue, 9 Feb 2021 15:53:05 +0000 (16:53 +0100)
adminer/drivers/mongo.inc.php

index 80b45b78ea9db07a4685174aedad15f202d17b40..260c658addd38ad8ebb9f3b5d02ba997bda0afbd 100644 (file)
@@ -27,16 +27,6 @@ if (isset($_GET["mongo"])) {
                                }
                        }
 
-                       function executeQuery($namespace, $where, $command) {
-                               $class = 'MongoDB\Driver\Query';
-                               try {
-                                       return $this->_link->executeQuery($namespace, new $class($where, $command));
-                               } catch (Exception $e) {
-                                       $this->error = $e->getMessage();
-                                       return array();
-                               }
-                       }
-
                        function query($query) {
                                return false;
                        }
@@ -136,8 +126,13 @@ if (isset($_GET["mongo"])) {
                                }
                                $limit = min(200, max(1, (int) $limit));
                                $skip = $page * $limit;
-                               $results = $connection->executeQuery("$connection->_db_name.$table", $where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort));
-                               return new Min_Result($results);
+                               $class = 'MongoDB\Driver\Query';
+                               try {
+                                       return new Min_Result($this->_link->executeQuery("$connection->_db_name.$table", new $class($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort))));
+                               } catch (Exception $e) {
+                                       $connection->error = $e->getMessage();
+                                       return false;
+                               }
                        }
 
                        function update($table, $set, $queryWhere, $limit = 0, $separator = "\n") {