function schema_phpprint_table in Schema 7
Same name and namespace in other branches
- 8 schema.module \schema_phpprint_table()
- 5 schema.module \schema_phpprint_table()
- 6 schema.module \schema_phpprint_table()
3 calls to schema_phpprint_table()
- drush_schema_inspect in ./
schema.drush.inc - Implements drush_COMMANDFILE_COMMANDNAME().
- schema_inspect in ./
schema.pages.inc - "Inspect" menu callback.
- schema_phpprint in ./
schema.module - Builds a pretty ASCII-formatted version of a $schema array.
File
- ./
schema.module, line 205 - The Schema module provides functionality built on the Schema API.
Code
function schema_phpprint_table($name, $table) {
$cols = array();
if (isset($table['fields'])) {
foreach ($table['fields'] as $colname => $col) {
$cols[] = "'{$colname}' => " . schema_phpprint_column($col, TRUE);
}
}
$unique = $index = array();
if (isset($table['unique keys'])) {
foreach ($table['unique keys'] as $keyname => $key) {
$unique[] = "'{$keyname}' => " . schema_phpprint_key($key);
}
}
if (isset($table['indexes'])) {
foreach ($table['indexes'] as $keyname => $key) {
$index[] = "'{$keyname}' => " . schema_phpprint_key($key);
}
}
if ($table['description']) {
$description = $table['description'];
}
else {
$description = t('TODO: please describe this table!');
}
$out = '';
$out .= "\$schema['" . $name . "'] = array(\n";
$out .= " 'description' => '{$description}',\n";
$out .= " 'fields' => array(\n ";
$out .= implode(",\n ", $cols);
$out .= ",\n ),\n";
if (isset($table['primary key'])) {
$out .= " 'primary key' => array('" . implode("', '", $table['primary key']) . "'),\n";
}
if (count($unique) > 0) {
$out .= " 'unique keys' => array(\n ";
$out .= implode(",\n ", $unique);
$out .= "\n ),\n";
}
if (count($index) > 0) {
$out .= " 'indexes' => array(\n ";
$out .= implode(",\n ", $index);
$out .= ",\n ),\n";
}
$out .= ");\n";
return $out;
}