function schema_phpprint_table in Schema 5
Same name and namespace in other branches
- 8 schema.module \schema_phpprint_table()
- 6 schema.module \schema_phpprint_table()
- 7 schema.module \schema_phpprint_table()
2 calls to schema_phpprint_table()
File
- ./
schema.module, line 22
Code
function schema_phpprint_table($name, $table) {
$cols = array();
foreach ($table['fields'] as $colname => $col) {
$cols[] = "'{$colname}' => " . schema_phpprint_column($col);
}
$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);
}
}
$out = '';
$out .= "\$schema['" . $name . "'] = array(\n 'fields' => array(\n ";
$out .= implode(",\n ", $cols);
$out .= "),\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";
}
if (count($index) > 0) {
$out .= " 'indexes' => array(\n ";
$out .= implode(",\n ", $index);
$out .= "),\n";
}
$out .= ");\n";
return $out;
}