From 4291e5d62c30f19e5edcf1f41c4d0f5d003d7393 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 4 Jul 2016 15:31:09 +0100 Subject: [PATCH] indexes --- lib/php/db/table.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/php/db/table.php b/lib/php/db/table.php index 97cddc1f..72aab783 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -163,8 +163,12 @@ Class Table extends nb { ; } - $sql_index = '';#$this->db()->type('table.sql.index',false); - return $sql_replace($sql.')'.($sql_index ? ';'.$this->db()->row($sql_index) : '')); + $indexes = [];#$this->db()->type('table.sql.index',false); + 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'].')'; + } + return $sql_replace($sql.')'.($indexes ? ';'.join(';',$indexes) : '')); } /* @@ -252,7 +256,7 @@ Class Table extends nb { // Get other indexes $indexes = []; foreach ($this->indexes() as $i) { - if (empty($i['unique'])) $indexes[$i['field']] = 1; + if (empty($i['unique']) and empty($i['key'])) $indexes[$i['field']] = 1; } foreach ($rows as $row) { -- 2.47.3