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)

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

1 call to drupal_schema_fields_sql()
node_load in drupal-6.x/modules/node/node.module
Load a node object from the database.

File

drupal-6.x/includes/common.inc, line 3476
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;
  }
}