1 common.inc backdrop_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

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

string $prefix: An optional prefix to to all fields.

Return value

array An array of fields.:

Related topics

File

core/includes/common.inc, line 8190
Common functions that many Backdrop modules will need to reference.

Code

function backdrop_schema_fields_sql($table, $prefix = NULL) {
  $schema = backdrop_get_schema($table);
  $fields = array_keys($schema['fields']);
  if ($prefix) {
    $columns = array();
    foreach ($fields as $field) {
      $columns[] = "$prefix.$field";
    }
    return $columns;
  }
  else {
    return $fields;
  }
}