From e002a3bc9946804808f2c9b48c1a177345b01110 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Tue, 9 Feb 2021 16:37:42 +0100 Subject: [PATCH] MongoDB: Display error when selecting wrong table --- adminer/drivers/mongo.inc.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/adminer/drivers/mongo.inc.php b/adminer/drivers/mongo.inc.php index 80b45b78..260c658a 100644 --- a/adminer/drivers/mongo.inc.php +++ b/adminer/drivers/mongo.inc.php @@ -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") {