MongoDB: Handle errors
This commit is contained in:
parent
609b8690ec
commit
6af375c67d
|
@ -6,7 +6,7 @@ if (isset($_GET["mongo"])) {
|
||||||
|
|
||||||
if (class_exists('MongoDB\Driver\Manager')) {
|
if (class_exists('MongoDB\Driver\Manager')) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var $extension = "MongoDB", $server_info = MONGODB_VERSION, $error, $last_id;
|
var $extension = "MongoDB", $server_info = MONGODB_VERSION, $affected_rows, $error, $last_id;
|
||||||
/** @var MongoDB\Driver\Manager */
|
/** @var MongoDB\Driver\Manager */
|
||||||
var $_link;
|
var $_link;
|
||||||
var $_db, $_db_name;
|
var $_db, $_db_name;
|
||||||
|
@ -26,6 +26,17 @@ if (isset($_GET["mongo"])) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function executeBulkWrite($namespace, $bulk, $counter) {
|
||||||
|
try {
|
||||||
|
$results = $this->_link->executeBulkWrite($namespace, $bulk);
|
||||||
|
$this->affected_rows = $results->$counter();
|
||||||
|
return true;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->error = $e->getMessage();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function query($query) {
|
function query($query) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -156,9 +167,7 @@ if (isset($_GET["mongo"])) {
|
||||||
$update['$unset'] = $removeFields;
|
$update['$unset'] = $removeFields;
|
||||||
}
|
}
|
||||||
$bulk->update($where, $update, array('upsert' => false));
|
$bulk->update($where, $update, array('upsert' => false));
|
||||||
$results = $connection->_link->executeBulkWrite("$db.$table", $bulk);
|
return $connection->executeBulkWrite("$db.$table", $bulk, 'getModifiedCount');
|
||||||
$connection->affected_rows = $results->getModifiedCount();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($table, $queryWhere, $limit = 0) {
|
function delete($table, $queryWhere, $limit = 0) {
|
||||||
|
@ -168,9 +177,7 @@ if (isset($_GET["mongo"])) {
|
||||||
$class = 'MongoDB\Driver\BulkWrite';
|
$class = 'MongoDB\Driver\BulkWrite';
|
||||||
$bulk = new $class(array());
|
$bulk = new $class(array());
|
||||||
$bulk->delete($where, array('limit' => $limit));
|
$bulk->delete($where, array('limit' => $limit));
|
||||||
$results = $connection->_link->executeBulkWrite("$db.$table", $bulk);
|
return $connection->executeBulkWrite("$db.$table", $bulk, 'getDeletedCount');
|
||||||
$connection->affected_rows = $results->getDeletedCount();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function insert($table, $set) {
|
function insert($table, $set) {
|
||||||
|
@ -182,9 +189,7 @@ if (isset($_GET["mongo"])) {
|
||||||
unset($set['_id']);
|
unset($set['_id']);
|
||||||
}
|
}
|
||||||
$bulk->insert($set);
|
$bulk->insert($set);
|
||||||
$results = $connection->_link->executeBulkWrite("$db.$table", $bulk);
|
return $connection->executeBulkWrite("$db.$table", $bulk, 'getInsertedCount');
|
||||||
$connection->affected_rows = $results->getInsertedCount();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ Oracle: Alter indexes
|
||||||
Oracle: Count tables
|
Oracle: Count tables
|
||||||
Oracle: Import from CSV
|
Oracle: Import from CSV
|
||||||
Oracle: Fix column size with string type
|
Oracle: Fix column size with string type
|
||||||
|
MongoDB: Handle errors
|
||||||
SimpleDB, Firebird, ClickHouse: Move to plugin
|
SimpleDB, Firebird, ClickHouse: Move to plugin
|
||||||
|
|
||||||
Adminer 4.7.9 (released 2021-02-07):
|
Adminer 4.7.9 (released 2021-02-07):
|
||||||
|
|
Loading…
Reference in a new issue