MongoDB: Display error when selecting wrong table

This commit is contained in:
Jakub Vrana 2021-02-09 16:37:42 +01:00
parent f44f186b38
commit e002a3bc99

View 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) { function query($query) {
return false; return false;
} }
@ -136,8 +126,13 @@ if (isset($_GET["mongo"])) {
} }
$limit = min(200, max(1, (int) $limit)); $limit = min(200, max(1, (int) $limit));
$skip = $page * $limit; $skip = $page * $limit;
$results = $connection->executeQuery("$connection->_db_name.$table", $where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort)); $class = 'MongoDB\Driver\Query';
return new Min_Result($results); 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") { function update($table, $set, $queryWhere, $limit = 0, $separator = "\n") {