public function addColumn(Type $column) { if (isset($this->exclude[$column->getName()])) { //trigger_error($this->name() . "." . $column->getName() . ": this column is not acceptable", E_USER_WARNING); throw new Exception(); } if ($column->getIndex() == self::ROLE_PRIMARY) { $this->combinedIndexes["PRIMARY"][$column->getIndex()][$column->getName()] = $column->getName(); } elseif ($column->getIndex() == self::ROLE_INDEX || $column->getIndex() == self::ROLE_UNIQUE) { $this->combinedIndexes[$column->getName()][$column->getIndex()][$column->getName()] = $column->getName(); } $this->exclude[$column->getName()] = $column->getName(); $this->columns[$column->getName()] = $column; return $this; }
protected function getSQLField(Type $type, $without_auto_increment = false) { $result = "`" . $type->getName() . "` " . $type->getType() . ""; if ($type->getLength()) { $result .= "(" . $type->getLength() . ")"; } if ($type->getAttribute()) { $result .= " {$type->getAttribute()}"; } if ($type->getCollate()) { $charset = explode("_", $type->getCollate(), 2); $result .= " CHARACTER SET " . $charset[0] . " COLLATE " . $type->getCollate(); } if ($type->isNull()) { $result .= " NULL"; } else { $result .= " NOT NULL"; } if ($type->getDefault() !== null) { if (is_string($type->getDefault()) && strlen($type->getDefault()) > 0 && $type->getDefault()[0] == "#") { $result .= " DEFAULT " . substr($type->getDefault(), -strlen($type->getDefault()) + 1); } else { $result .= " DEFAULT '{$type->getDefault()}'"; } } if ($type->isAutoIncrement() && !$without_auto_increment) { $result .= " auto_increment"; } return $result; }