]> git.joonet.de Git - adminer.git/commitdiff
MongoDB: Fix insert form with empty table
authorJakub Vrana <jakub@vrana.cz>
Sat, 11 Jan 2014 23:16:26 +0000 (15:16 -0800)
committerJakub Vrana <jakub@vrana.cz>
Sat, 11 Jan 2014 23:16:26 +0000 (15:16 -0800)
adminer/edit.inc.php

index 2a6f0a16d60e6431a5bd3755331a71b8964892df..faa3434dc86a0d5051cc14639c52ac63e1beb7a3 100644 (file)
@@ -100,8 +100,13 @@ if ($_POST["save"]) {
 if (!support("table") && !$fields) {
        $id = ($jush == "mongo" ? "_id" : "itemName()"); // simpledb
        if (!$where) { // insert
-               $row = $driver->select($TABLE, array("*"), $where, array("*"), array(), 1, 0);
-               $row = ($row ? $row->fetch_assoc() : array($id => ""));
+               $result = $driver->select($TABLE, array("*"), $where, array("*"), array(), 1, 0);
+               if ($result) {
+                       $row = $result->fetch_assoc();
+               }
+               if (!$row) {
+                       $row = array($id => "");
+               }
        }
        if ($row) {
                foreach ($row as $key => $val) {