return $sql_replace('CREATE VIEW '.$this->sql_name().' AS '.preg_replace('/^CREATE\s+.*?\s+AS\s+.*?SELECT/i','SELECT',$this->sql()));
}
- $type = $this->db()->type;
- if (!empty($db_type)) $this->db()->type = $db_type;
-
$indexes = [];
foreach ($this->indexes() as $i) {
if (!empty($i['unique']) or !empty($i['key'])) continue;
$indexes[] = 'CREATE INDEX '.$i['name'].' ON '.$this->sql_name().' ('.$i['field'].')';
}
+ # Get all fields
+ $fields = [];
+ foreach ($this->fields() as $f) {
+ if (!empty($f->extras)) continue;
+ $fields[] = $f;
+ }
+
+ $type = $this->db()->type;
+ if (!empty($db_type)) $this->db()->type = $db_type;
+
// Specific function for fields if return something use it instead of default
$_create_fct = $this->db()->conf_type('field.create',false);
$_create = function(&$field) use ($_create_fct) {
;
};
- # Get all fields
- $fields = [];
- foreach ($this->fields() as $f) {
- if (!empty($f->extras)) continue;
- $fields[] = $f;
- }
-
$sql = 'CREATE '.strtoupper($this->type()).' '.$this->sql_name()
.' ('
.join(",",array_map(function($f) use ($_create) {return $_create($f);},$fields))
$rows = $obj;
} elseif (empty($meth)) {
+ if ($this->is_html) echo '<div class="block">'.NB_EOL;
echo $obj;
+ if ($this->is_html) echo '</div>'.NB_EOL;
} elseif (is_array($meth)) {
$rows = $meth;
[ 'replace', 'Replace record' ],
[ 'rm', 'Remove record' ],
[ 'add', 'Record record' ],
+ [ 'schema', 'Sql schema [/DB_TYPE]' ],
[ 'status', 'Status page' ],
],['command','description'],function(&$r){
$r['command'] = $this->page->tag('a',$r['command'],'href="'
$this->page_table_ls($this->params['args']);
} elseif ($action == 'schema') {
- $this->page(preg_replace('/\s*;\s*$/','',$this->table->create(true,$this->params['args'])).";\n");
+ $this->page(preg_replace('/\s*;\s*$/','',$this->table->create(false,$this->params['args'])).";\n");
} elseif ($action == 'sql') {
$this->page(['sql'=>$this->table->sql()]);