function schema_phpprint_column in Schema 8
Same name and namespace in other branches
- 5 schema.module \schema_phpprint_column()
- 6 schema.module \schema_phpprint_column()
- 7 schema.module \schema_phpprint_column()
2 calls to schema_phpprint_column()
- schema_phpprint_table in ./
schema.module - TableComparisonInfoBuilder::getInfoArray in src/
Comparison/ TableComparisonInfoBuilder.php
File
- ./
schema.module, line 167 - The Schema module provides functionality built on the Schema API.
Code
function schema_phpprint_column($col, $multiline = FALSE) {
$attrs = array();
$description = isset($col['description']) ? $col['description'] : '';
unset($col['description']);
$attrs[] = "'description' => '{$description}'";
if ($col['type'] == 'varchar' || $col['size'] == 'normal') {
unset($col['size']);
}
foreach (array(
'type',
'unsigned',
'size',
'length',
'not null',
'default',
) as $attr) {
if (isset($col[$attr])) {
if (is_string($col[$attr])) {
$attrs[] = "'{$attr}' => '{$col[$attr]}'";
}
elseif (is_bool($col[$attr])) {
$attrs[] = "'{$attr}' => " . ($col[$attr] ? 'TRUE' : 'FALSE');
}
else {
$attrs[] = "'{$attr}' => {$col[$attr]}";
}
unset($col[$attr]);
}
}
foreach (array_keys($col) as $attr) {
if (is_string($col[$attr])) {
$attrs[] = "'{$attr}' => '{$col[$attr]}'";
}
else {
$attrs[] = "'{$attr}' => {$col[$attr]}";
}
}
if ($multiline) {
return "array(\n " . implode(",\n ", $attrs) . ",\n )";
}
return "array(" . implode(', ', $attrs) . ")";
}