port db_indexes() from zap

This commit is contained in:
Mario Vavti 2019-05-13 10:46:12 +02:00
parent d5f59a57bf
commit fbe8d6144a

View File

@ -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 [];
}