- self::createview($name, $structure, $verbose, $action);
- }
- }
-
- public static function printStructure($basePath)
- {
- $database = self::definition($basePath, false);
-
- foreach ($database AS $name => $structure) {
- echo "--\n";
- echo "-- VIEW $name\n";
- echo "--\n";
- self::createView($name, $structure, true, false);
-
- echo "\n";
- }
- }
-
- private static function createview($name, $structure, $verbose, $action)
- {
- $r = true;
-
- $sql_rows = [];
- foreach ($structure["fields"] AS $fieldname => $origin) {
- if (is_string($origin)) {
- $sql_rows[] = $origin . " AS `" . DBA::escape($fieldname) . "`";
- } elseif (is_array($origin) && (sizeof($origin) == 2)) {
- $sql_rows[] = "`" . DBA::escape($origin[0]) . "`.`" . DBA::escape($origin[1]) . "` AS `" . DBA::escape($fieldname) . "`";
+ if (self::isView($name)) {
+ DBA::e(sprintf("DROP VIEW IF EXISTS `%s`", DBA::escape($name)));
+ } elseif (self::isTable($name)) {
+ DBA::e(sprintf("DROP TABLE IF EXISTS `%s`", DBA::escape($name)));