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,24 +238,26 @@ if (isset($_GET["mongo"])) {
} }
function fields($table) { function fields($table) {
global $driver;
$fields = fields_from_edit(); $fields = fields_from_edit();
if (!count($fields)) { if (!$fields) {
global $driver;
$result = $driver->select($table, array("*"), null, null, array(), 10); $result = $driver->select($table, array("*"), null, null, array(), 10);
while ($row = $result->fetch_assoc()) { if ($result) {
foreach ($row as $key => $val) { while ($row = $result->fetch_assoc()) {
$row[$key] = null; foreach ($row as $key => $val) {
$fields[$key] = array( $row[$key] = null;
"field" => $key, $fields[$key] = array(
"type" => "string", "field" => $key,
"null" => ($key != $driver->primary), "type" => "string",
"auto_increment" => ($key == $driver->primary), "null" => ($key != $driver->primary),
"privileges" => array( "auto_increment" => ($key == $driver->primary),
"insert" => 1, "privileges" => array(
"select" => 1, "insert" => 1,
"update" => 1, "select" => 1,
), "update" => 1,
); ),
);
}
} }
} }
} }