From 77f6c7e268b869b2d7a25960ca737f9e50a63136 Mon Sep 17 00:00:00 2001 From: Nico Boisselier Date: Thu, 27 Oct 2016 11:52:31 +0100 Subject: [PATCH] mysql table.sql.index --- lib/php/db.php | 6 +++--- lib/php/db/table.php | 7 ------- lib/php/db/types/mysql.php | 2 +- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/php/db.php b/lib/php/db.php index 514ea6ee..df7542a5 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -62,6 +62,7 @@ class Db extends nb { 'databases' => 'db.databases', 'tables' => 'db.tables', + 'help' => 'db.help', 'fields' => 'table.fields', 'rows' => 'table.rows', 'insert' => 'table.insert', @@ -506,7 +507,7 @@ class Db extends nb { foreach($actions as $action) { - if ($action == 'db.help' or $action == 'help') { + if ($action == 'db.help') { $this->out($available,['action','description']); $return = true; @@ -524,11 +525,10 @@ class Db extends nb { 'count' => $count, ]); - } elseif ($action == 'db.tables' or $action == 'tables') { + } elseif ($action == 'db.tables') { # Filters $type = $this->p('type',''); $name = $this->p('name',''); - #if ($count = $this->p('count','')) $this->pset('count',1); $engine = $this->p('engine',''); #var_dump ($this->tables()); diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 075dc817..843cdf1c 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -1398,13 +1398,6 @@ Class Table extends nb { public function action($action=null) { if ($action === null) $action = $this->p('action'); -# NB 23.05.16 $aliases = function($search) { -# NB 23.05.16 foreach ([ -# NB 23.05.16 [ 'table.fields', 'fields' ], -# NB 23.05.16 ] as $k=>$v) { -# NB 23.05.16 if ($k === $search or $v === $search) return $k; -# NB 23.05.16 } -# NB 23.05.16 }; if ($action == 'table.fields') { $rows = array_values($this->object2array($this->fields())); diff --git a/lib/php/db/types/mysql.php b/lib/php/db/types/mysql.php index bcc6ff2f..6f448d20 100644 --- a/lib/php/db/types/mysql.php +++ b/lib/php/db/types/mysql.php @@ -15,7 +15,7 @@ $DB_TYPES['mysql'] = array ( 'file2table' => "LOAD DATA INFILE ' REPLACE INTO TABLE '' TERMINATED BY '\\t' ENCLOSED BY '' LINES TERMINATED BY '\\r\\n' IGNORE 0 LINES", 'table.sql' => 'SHOW CREATE TABLE ``', -'table.sql.index' => "SELECT ".(Db::p('db.type') ? "CONCAT(s.TABLE_NAME,'_',s.INDEX_NAME,'_idx')" : 's.INDEX_NAME')." as name,(CASE NON_UNIQUE WHEN 1 THEN 0 ELSE 1 END) as uniqe,GROUP_CONCAT(COLUMN_NAME) as field FROM INFORMATION_SCHEMA.STATISTICS s LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON t.TABLE_SCHEMA=s.TABLE_SCHEMA AND t.TABLE_NAME=s.TABLE_NAME AND s.INDEX_NAME=t.CONSTRAINT_NAME WHERE 0=0 AND t.CONSTRAINT_NAME IS NULL AND s.TABLE_SCHEMA = DATABASE() AND s.TABLE_NAME='' GROUP BY name ORDER BY SEQ_IN_INDEX", +'table.sql.index' => "SELECT ".(Db::p('db.type') ? "CONCAT(s.TABLE_NAME,'_',s.INDEX_NAME,'_idx')" : 's.INDEX_NAME')." as name,(CASE NON_UNIQUE WHEN 1 THEN 0 ELSE 1 END) as uniqe,GROUP_CONCAT(COLUMN_NAME) as field FROM INFORMATION_SCHEMA.STATISTICS s LEFT OUTER JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS t ON t.TABLE_SCHEMA=s.TABLE_SCHEMA AND t.TABLE_NAME=s.TABLE_NAME AND s.INDEX_NAME=t.CONSTRAINT_NAME WHERE 0=0 AND t.CONSTRAINT_NAME IS NULL AND s.TABLE_SCHEMA = DATABASE() AND s.TABLE_NAME='' GROUP BY name,uniqe,SEQ_IN_INDEX ORDER BY SEQ_IN_INDEX", # NB 04.07.16 '_table.sql.index' => [ # NB 04.07.16 'SHOW INDEX FROM ``', function(&$r) { # NB 04.07.16 if ($r['Key_name'] != 'PRIMARY') return [ -- 2.47.3