]> git.mxchange.org Git - friendica.git/blobdiff - src/Database/View.php
"id" is now post-user-id
[friendica.git] / src / Database / View.php
index bfdcdff7caf7c78a25a74bc72b76e985da859b0b..e49eb8cc51cfcc7f664b1054e83cc1eff823401a 100644 (file)
@@ -112,16 +112,16 @@ class View
                }
 
                if (self::isView($name)) {
-                       $sql = sprintf("DROP VIEW `%s`", DBA::escape($name));
+                       $sql = sprintf("DROP VIEW IF EXISTS `%s`", DBA::escape($name));
                } elseif (self::isTable($name)) {
-                       $sql = sprintf("DROP TABLE `%s`", DBA::escape($name));
+                       $sql = sprintf("DROP TABLE IF EXISTS `%s`", DBA::escape($name));
                }
 
-               if ($verbose) {
+               if (!empty($sql) && $verbose) {
                        echo $sql . ";\n";
                }
 
-               if ($action) {
+               if (!empty($sql) && $action) {
                        DBA::e($sql);
                }
 
@@ -158,7 +158,7 @@ class View
        }
 
        /**
-        * Check if the given table/view is a view
+        * Check if the given table/view is a table
         *
         * @param string $table
         * @return boolean "true" if it's a table
@@ -168,10 +168,10 @@ class View
                $status = DBA::selectFirst(['INFORMATION_SCHEMA' => 'TABLES'], ['TABLE_TYPE'],
                        ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_NAME' => $table]);
 
-                       if (empty($status['TABLE_TYPE'])) {
-                               return false;
-                       }
+               if (empty($status['TABLE_TYPE'])) {
+                       return false;
+               }
 
-                       return $status['TABLE_TYPE'] == 'BASE TABLE';
+               return $status['TABLE_TYPE'] == 'BASE TABLE';
        }
 }