#if (NB_EOL == "\n")
# Cache before changing db type
- foreach ($tables as $t) {
+ foreach ($tables as $k=>$t) {
unset($t->orderby);
$t->fields();
$t->sql();
+ if ($t->type == 'sql') unset($tables[$k]);
}
echo ''
}
$type = self::p('type','');
- $name = self::p('name','');
+ $name = self::p('name',self::p('table',''));
foreach ($this->sql_exec() as $s) {
echo rtrim($s,';').";\n";
}
#echo 'DROP TABLE IF EXISTS '.$t->sql_name().';'.NB_EOL;
echo 'DROP '.strtoupper($t->type).' IF EXISTS '.$t->sql_name().';'.NB_EOL;
- echo str_replace(';CREATE',";\nCREATE",rtrim($t->create(),';')).';'.NB_EOL;
+
+ $sql = rtrim($t->create(),';');
+ $sql = str_replace(';CREATE',";\nCREATE",$sql);
+ #$sql = preg_replace('/;CREATE\s+(INDEX)\s+(\S+)(\s+ON\s+\S+[^;]+)/',";\nDROP $1 IF EXISTS $2;\nCREATE $1 $2",$sql);
+ echo $sql.';'.NB_EOL;
+
if ($insert and $t->type == 'table') $t->rows();
#break;
}