From: Nicolas Boisselier Date: Wed, 10 Jan 2018 01:27:42 +0000 (+0000) Subject: lib/php/db/table.php X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=4ae795db2aab535f8929d2d2d0b8a812772681c0;p=nb.git lib/php/db/table.php --- diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 4bbf3042..c4b9e2b5 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1391,8 +1391,9 @@ Class Table extends nb { $keys[] = $f->sql_name(); } - $sql = "INSERT INTO ".$this->sql_name()." VALUES (".join(',',array_values($values)).");"; - #$sql = "INSERT INTO ".$this->sql_name()." (".join(',',$keys).") VALUES (".join(',',array_values($values)).");"; + $fields = $this->fields_only ? ' ('.join(',',$keys).')' : ''; + $sql = "INSERT INTO ".$this->sql_name().$fields." VALUES(".join(',',array_values($values)).");"; + #if ($fct and $this->name=='place') debug($sql); $fct = !empty($opt['fct']) ? $opt['fct'] : null; if ($fct) $sql = $fct($sql,$this); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index b1d4d547..c514cae7 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -1210,6 +1210,7 @@ EOF; [ 'rm', 'Remove record' ], [ 'add', 'Record record' ], [ 'schema', 'Sql schema [/DB_TYPE]' ], + [ 'count', 'Count records' ], [ 'status', 'Status page' ], ],['command','description'],function(&$r){ $r['command'] = $this->page->tag('a',$r['command'],'href="' @@ -1226,9 +1227,6 @@ EOF; } elseif ($action == 'schema') { $this->page(preg_replace('/\s*;\s*$/','',$this->table->create(false,$this->params['args'])).";\n"); - } elseif ($action == 'sql') { - $this->page(['sql'=>$this->table->sql()]); - } elseif ($action == 'count') { $this->page(['count'=>$this->table->rows_count()]);