function drupal_schema_fields_sql

7.x common.inc drupal_schema_fields_sql($table, $prefix = NULL)
6.x common.inc drupal_schema_fields_sql($table, $prefix = NULL)

Retrieves a list of fields from a table schema.

The returned list is suitable for use in an 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

3 calls to drupal_schema_fields_sql()
entity_get_info in drupal-7.x/includes/common.inc
Get the entity info array of an entity type.
system_admin_menu_block in drupal-7.x/modules/system/system.module
Provide a single block on the administration overview page.
system_get_module_admin_tasks in drupal-7.x/modules/system/system.module
Generate a list of tasks offered by a specified module.

File

drupal-7.x/includes/common.inc, line 7057
Common functions that many Drupal modules will need to reference.

Code

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;
  }
}