Exemplo n.º 1
0
 public function length($length)
 {
     if ($this->column->isString() || $this->isChange && $this->column->type === null) {
         $this->column->max = $length;
         return $this;
     } else {
         Sabel_Console::error("length() for _STRING column.");
         exit;
     }
 }
Exemplo n.º 2
0
 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;
 }