You are here

function dba_get_fields in Database Administration 5

Same name and namespace in other branches
  1. 7 dba.admin.inc \dba_get_fields()

Return all fields in specified table as array.

Related topics

3 calls to dba_get_fields()
dba_backup_table in ./dba.module
Backup table to file.
dba_edit_row_submit in ./dba.module
dba_table_overview in ./dba.module

File

./dba.module, line 1346
Allows administrators direct access to their Drupal database. Written by Jeremy Andrews <jeremy@kerneltrap.org>, June 2004. PostgreSQL functionality provided by AAM <aam@ugpl.de> Major security audit, porting, and maintenance by Derek…

Code

function dba_get_fields($table) {
  $fields = array();
  if (_is_mysql()) {
    $result = db_query("DESCRIBE {$table}");
    while ($row = db_fetch_object($result)) {
      $fields[] = $row->Field;
    }
  }
  else {

    // Lowercase of names of resulting columns seems to be important for postgresql.
    $result = db_query("SELECT colname as field FROM {drupal_system_catalog} WHERE tabname = '" . $table . "'");
    while ($row = db_fetch_object($result)) {
      $fields[] = $row->field;
    }
  }
  return $fields;
}