예제 #1
0
 public function apply(\blaze\ds\meta\ColumnMetaData $meta)
 {
     $this->name = $meta->getName();
     $this->className = $meta->getClassType();
     $this->comment = $meta->getComment();
     $this->default = $meta->getDefault();
     $this->length = $meta->getLength();
     $this->precision = $meta->getPrecision();
     $this->foreignKey = $meta->isForeignKey();
     $this->primaryKey = $meta->isPrimaryKey();
     $this->uniqueKey = $meta->isUniqueKey();
     $this->nullable = $meta->isNullable();
     $this->signed = $meta->isSigned();
 }
예제 #2
0
 public static function getColumnDefinition(\blaze\ds\meta\ColumnMetaData $column, $newName = null, $nullable = true, $default = true, $sequence = true, $primary = true, $unique = true, $comment = true)
 {
     if ($newName === null) {
         $query = $column->getName() . ' ' . $column->getComposedNativeType();
     } else {
         $query = $newName . ' ' . $column->getComposedNativeType();
     }
     if ($nullable && !$column->isNullable()) {
         $query .= ' NOT NULL';
     }
     if ($default && $column->getDefault() !== null) {
         $query .= ' DEFAULT ' . $column->getDefault();
     }
     if ($sequence && $column->getSequence() !== null) {
         $query .= ' AUTO_INCREMENT';
     }
     if ($primary && $column->isPrimaryKey()) {
         $query .= ' PRIMARY KEY';
     } else {
         if ($unique && $column->isUniqueKey()) {
             $query .= ' UNIQUE KEY';
         }
     }
     if ($comment && $column->getComment() !== null) {
         $query .= ' COMMENT \'' . $column->getComment() . '\'';
     }
     return $query;
 }