drupal_schema_fields_sql
Definition
drupal_schema_fields_sql($table, $prefix = NULL)
includes/common.inc, line 3204
Description
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
| Name | Description |
|---|---|
| Schema API | A Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema(), which usually lives in a modulename.install file. |
Code
<?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;
}
}
?> 