drupal_schema_fields_sql

Versions
6 – 7
drupal_schema_fields_sql($table, $prefix = NULL)

Retrieve a list of fields from a table schema. The list is suitable for use in a SQL query.

Parameters

$table The name of the table from which to retrieve fields.

An optional prefix to to all fields.

Return value

An array of fields.

Related topics

Code

includes/common.inc, line 3347

<?php
function drupal_schema_fields_sql($table, $prefix = NULL) {
  $schema = drupal_get_schema($table);
  $fields = array_keys($schema['fields']);
  if ($prefix) {
    $columns = array();
    foreach ($fields as $field) {
      $columns[] = "$prefix.$field";
    }
    return $columns;
  }
  else {
    return $fields;
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.