You are here

function schema_phpprint_column in Schema 5

Same name and namespace in other branches
  1. 8 schema.module \schema_phpprint_column()
  2. 6 schema.module \schema_phpprint_column()
  3. 7 schema.module \schema_phpprint_column()
2 calls to schema_phpprint_column()
schema_compare_table in ./schema.module
schema_phpprint_table in ./schema.module

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) . ")";
}