diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-05-02 09:22:23 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-05-02 09:22:23 +0200 |
commit | 9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e (patch) | |
tree | 08ab408a73711eedbc231ba3bfb3325cdb7842b9 /include/dba | |
parent | 3f75dd108374d24674436c58deb9d2a795fbf604 (diff) | |
parent | 7a55ead97db94284146612364b8ce1c59de8771f (diff) | |
download | volse-hubzilla-9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e.tar.gz volse-hubzilla-9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e.tar.bz2 volse-hubzilla-9615d02b353f37e1747dd6f10ee8a4c8b8cc7b2e.zip |
Merge remote-tracking branch 'mike/master' into dev
Diffstat (limited to 'include/dba')
-rwxr-xr-x | include/dba/dba_driver.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index b3298b673..9e9f24bb3 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -460,3 +460,28 @@ function db_logger($s,$level = LOGGER_NORMAL,$syslog = LOG_INFO) { \DBA::$logging = false; \DBA::$dba->debug = $saved; } + + +function db_columns($table) { + + if($table) { + if(ACTIVE_DBTYPE === DBTYPE_POSTGRES) { + $r = q("SELECT column_name as field FROM information_schema.columns WHERE table_schema = 'public' AND table_name = '%s'", + dbesc($table) + ); + if($r) { + return ids_to_array($r,'field'); + } + } + else { + $r = q("show columns in %s", + dbesc($table) + ); + if($r) { + return ids_to_array($r,'Field'); + } + } + } + + return []; +}
\ No newline at end of file |