MongoDB: Fix query

This commit is contained in:
Jakub Vrana 2021-02-09 19:46:33 +01:00
parent 13260dcb76
commit 609b8690ec

View file

@ -128,7 +128,7 @@ if (isset($_GET["mongo"])) {
$skip = $page * $limit; $skip = $page * $limit;
$class = 'MongoDB\Driver\Query'; $class = 'MongoDB\Driver\Query';
try { try {
return new Min_Result($this->_link->executeQuery("$connection->_db_name.$table", new $class($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort)))); return new Min_Result($connection->_link->executeQuery("$connection->_db_name.$table", new $class($where, array('projection' => $select, 'limit' => $limit, 'skip' => $skip, 'sort' => $sort))));
} catch (Exception $e) { } catch (Exception $e) {
$connection->error = $e->getMessage(); $connection->error = $e->getMessage();
return false; return false;
@ -189,7 +189,6 @@ if (isset($_GET["mongo"])) {
} }
function get_databases($flush) { function get_databases($flush) {
/** @var Min_DB */
global $connection; global $connection;
$return = array(); $return = array();
foreach ($connection->executeCommand('admin', array('listDatabases' => 1)) as $dbs) { foreach ($connection->executeCommand('admin', array('listDatabases' => 1)) as $dbs) {
@ -239,10 +238,11 @@ if (isset($_GET["mongo"])) {
} }
function fields($table) { function fields($table) {
$fields = fields_from_edit();
if (!count($fields)) {
global $driver; global $driver;
$fields = fields_from_edit();
if (!$fields) {
$result = $driver->select($table, array("*"), null, null, array(), 10); $result = $driver->select($table, array("*"), null, null, array(), 10);
if ($result) {
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
foreach ($row as $key => $val) { foreach ($row as $key => $val) {
$row[$key] = null; $row[$key] = null;
@ -260,6 +260,7 @@ if (isset($_GET["mongo"])) {
} }
} }
} }
}
return $fields; return $fields;
} }