X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FDatabase%2FView.php;h=e0d30481524d3bb0c6fe07b2806dfaa202b5c1cc;hb=f26226229a45af4053055b8a5ea7aa0f7aa33e0c;hp=bfdcdff7caf7c78a25a74bc72b76e985da859b0b;hpb=7e6a9bd893eee66dfb1119bd291fa993e0688706;p=friendica.git diff --git a/src/Database/View.php b/src/Database/View.php index bfdcdff7ca..e0d3048152 100644 --- a/src/Database/View.php +++ b/src/Database/View.php @@ -1,6 +1,6 @@ $structure) { @@ -112,16 +126,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 +172,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 +182,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'; } }