From fbe8d6144aeaed179aaccd7724aba51e4ca000a8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 May 2019 10:46:12 +0200 Subject: port db_indexes() from zap --- include/dba/dba_driver.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include/dba') diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index ee0e06a91..cfb208e2d 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -485,3 +485,28 @@ function db_columns($table) { return []; } + + +function db_indexes($table) { + + if($table) { + if(ACTIVE_DBTYPE === DBTYPE_POSTGRES) { + $r = q("SELECT indexname from pg_indexes where tablename = '%s'", + dbesc($table) + ); + if($r) { + return ids_to_array($r,'indexname'); + } + } + else { + $r = q("show index from %s", + dbesc($table) + ); + if($r) { + return ids_to_array($r,'Key_name'); + } + } + } + + return []; +} -- cgit v1.2.3