public function value($value) { if ($this->column->isBool() && !is_bool($value)) { Sabel_Console::error("default value for BOOL column should be a boolean."); exit; } else { $this->column->default = $value; return $this; } }
protected function createColumn($row) { $column = new Sabel_Db_Metadata_Column(); $column->name = strtolower($row["column_name"]); $column->nullable = $row["nullable"] !== "N"; $type = strtolower($row["data_type"]); $default = trim($row["data_default"]); $precision = (int) $row["data_precision"]; if ($type === "number") { if ($precision === 1 && ($default === "1" || $default === "0")) { $column->type = Sabel_Db_Type::BOOL; } else { if ($precision === 5) { $type = "smallint"; } elseif ($precision === 19) { $type = "bigint"; } else { $type = "integer"; } } } if (!$column->isBool()) { if ($type === "float") { $type = $precision === 24 ? "float" : "double"; } elseif ($type === "date" && !$this->isDate($column->name)) { $type = "datetime"; } Sabel_Db_Type_Manager::create()->applyType($column, $type); } $this->setDefault($column, $default); $seq = $row["table_name"] . "_" . $row["column_name"] . "_seq"; $column->increment = in_array(strtoupper($seq), $this->sequences); $column->primary = in_array($column->name, $this->primaryKeys); if ($column->primary) { $column->nullable = false; } if ($column->isString()) { $column->max = (int) $row["char_length"]; } return $column; }