@@ -12,7 +12,7 @@ |
||
12 | 12 | abstract class TableCreator |
13 | 13 | { |
14 | 14 | protected static $map = [ |
15 | - 'mysql' => MySQLTableCreator::class, |
|
15 | + 'mysql' => MySQLTableCreator::class, |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | abstract function create(Connection $connection, TableStruct $fields); |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $table = $this->fields->getRealTableName($this->connection); |
99 | 99 | $sql = "CREATE TABLE IF NOT EXISTS `{$table}` (\r\n\t"; |
100 | 100 | $sql .= implode(",\r\n\t", array_filter($content, 'strlen')); |
101 | - $auto = null === $this->auto?'':'AUTO_INCREMENT='.$this->auto; |
|
102 | - $collate = null === $this->collate?'':'COLLATE '.$this->collate; |
|
101 | + $auto = null === $this->auto ? '' : 'AUTO_INCREMENT='.$this->auto; |
|
102 | + $collate = null === $this->collate ? '' : 'COLLATE '.$this->collate; |
|
103 | 103 | $sql .= "\r\n) ENGINE={$this->engine} {$collate} {$auto} DEFAULT CHARSET={$this->charset};"; |
104 | 104 | return $sql; |
105 | 105 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | } |
119 | 119 | if (count($primary)) { |
120 | - return 'PRIMARY KEY ('. implode(',', $primary).')'; |
|
120 | + return 'PRIMARY KEY ('.implode(',', $primary).')'; |
|
121 | 121 | } |
122 | 122 | return ''; |
123 | 123 | } |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | protected function createField(Field $field) |
211 | 211 | { |
212 | 212 | $type = strtoupper($field->getValueType()).$this->parseLength($field->getLength()); |
213 | - $auto = $field->getAuto() ?'AUTO_INCREMENT':''; |
|
214 | - $null = $field->isNullable() === null? '': $field->isNullable() === true ? 'NULL':'NOT NULL'; |
|
215 | - $attr = $field->getAttribute() ?strtoupper($field->getAttribute()):''; |
|
216 | - $comment = $field->getComment() ?('COMMENT \''.addcslashes($field->getComment(), '\'').'\''):''; |
|
213 | + $auto = $field->getAuto() ? 'AUTO_INCREMENT' : ''; |
|
214 | + $null = $field->isNullable() === null ? '' : $field->isNullable() === true ? 'NULL' : 'NOT NULL'; |
|
215 | + $attr = $field->getAttribute() ?strtoupper($field->getAttribute()) : ''; |
|
216 | + $comment = $field->getComment() ? ('COMMENT \''.addcslashes($field->getComment(), '\'').'\'') : ''; |
|
217 | 217 | // default设置 |
218 | 218 | if ($field->hasDefault()) { |
219 | 219 | if (null === $field->getDefault()) { |