function schema_phpprint_column in Schema 5
Same name and namespace in other branches
- 8 schema.module \schema_phpprint_column()
- 6 schema.module \schema_phpprint_column()
- 7 schema.module \schema_phpprint_column()
2 calls to schema_phpprint_column()
File
- ./
schema.module, line 59
Code
function schema_phpprint_column($col) {
$attrs = array();
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]}'";
}
else {
if (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]}";
}
}
return "array(" . implode(', ', $attrs) . ")";
}