@@ -77,14 +77,14 @@ |
||
| 77 | 77 | */ |
| 78 | 78 | # public function index($name):CreateTableInterface; |
| 79 | 79 | |
| 80 | - public function tinyint(string $name, int $length = null, int $defaultValue = null , bool $isNull = null, string $attribute = null):CreateTableInterface; |
|
| 81 | - public function int(string $name, int $length = null, int $defaultValue = null , bool $isNull = null, string $attribute = null):CreateTableInterface; |
|
| 80 | + public function tinyint(string $name, int $length = null, int $defaultValue = null, bool $isNull = null, string $attribute = null):CreateTableInterface; |
|
| 81 | + public function int(string $name, int $length = null, int $defaultValue = null, bool $isNull = null, string $attribute = null):CreateTableInterface; |
|
| 82 | 82 | |
| 83 | - public function tinytext(string $name, int $defaultValue = null , bool $isNull = true):CreateTableInterface; |
|
| 84 | - public function text(string $name, int $defaultValue = null , bool $isNull = true):CreateTableInterface; |
|
| 83 | + public function tinytext(string $name, int $defaultValue = null, bool $isNull = true):CreateTableInterface; |
|
| 84 | + public function text(string $name, int $defaultValue = null, bool $isNull = true):CreateTableInterface; |
|
| 85 | 85 | |
| 86 | - public function varchar(string $name, int $length, int $defaultValue = null , bool $isNull = null):CreateTableInterface; |
|
| 87 | - public function decimal(string $name, string $length, int $defaultValue = null , bool $isNull = null):CreateTableInterface; |
|
| 88 | - public function enum(string $name, array $values, $defaultValue = null , bool $isNull = null):CreateTableInterface; |
|
| 86 | + public function varchar(string $name, int $length, int $defaultValue = null, bool $isNull = null):CreateTableInterface; |
|
| 87 | + public function decimal(string $name, string $length, int $defaultValue = null, bool $isNull = null):CreateTableInterface; |
|
| 88 | + public function enum(string $name, array $values, $defaultValue = null, bool $isNull = null):CreateTableInterface; |
|
| 89 | 89 | |
| 90 | 90 | } |
@@ -176,12 +176,12 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @return \chillerlan\Database\Query\CreateTableInterface |
| 178 | 178 | */ |
| 179 | - public function tinyint(string $name, int $length = null, int $defaultValue = null , bool $isNull = null, string $attribute = null):CreateTableInterface{ |
|
| 179 | + public function tinyint(string $name, int $length = null, int $defaultValue = null, bool $isNull = null, string $attribute = null):CreateTableInterface{ |
|
| 180 | 180 | return $this->field($name, 'TINYINT', $length, null, null, !is_null($defaultValue) ? false : $isNull, !is_null($defaultValue) ? 'USER_DEFINED' : null, $defaultValue); |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
| 184 | - public function int(string $name, int $length = null, int $defaultValue = null , bool $isNull = null, string $attribute = null):CreateTableInterface{ |
|
| 184 | + public function int(string $name, int $length = null, int $defaultValue = null, bool $isNull = null, string $attribute = null):CreateTableInterface{ |
|
| 185 | 185 | return $this->field($name, 'INT', $length, null, null, !is_null($defaultValue) ? false : $isNull, !is_null($defaultValue) ? 'USER_DEFINED' : null, $defaultValue); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @return \chillerlan\Database\Query\CreateTableInterface |
| 196 | 196 | */ |
| 197 | - public function varchar(string $name, int $length, int $defaultValue = null , bool $isNull = null):CreateTableInterface{ |
|
| 197 | + public function varchar(string $name, int $length, int $defaultValue = null, bool $isNull = null):CreateTableInterface{ |
|
| 198 | 198 | return $this->field($name, 'VARCHAR', $length, null, null, !is_null($defaultValue) ? false : $isNull, !is_null($defaultValue) ? 'USER_DEFINED' : null, $defaultValue); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | * |
| 207 | 207 | * @return \chillerlan\Database\Query\CreateTableInterface |
| 208 | 208 | */ |
| 209 | - public function decimal(string $name, string $length, int $defaultValue = null , bool $isNull = null):CreateTableInterface{ |
|
| 209 | + public function decimal(string $name, string $length, int $defaultValue = null, bool $isNull = null):CreateTableInterface{ |
|
| 210 | 210 | return $this->field($name, 'DECIMAL', $length, null, null, !is_null($defaultValue) ? false : $isNull, !is_null($defaultValue) ? 'USER_DEFINED' : null, $defaultValue); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return \chillerlan\Database\Query\CreateTableInterface |
| 219 | 219 | */ |
| 220 | - public function tinytext(string $name, int $defaultValue = null , bool $isNull = true):CreateTableInterface{ |
|
| 220 | + public function tinytext(string $name, int $defaultValue = null, bool $isNull = true):CreateTableInterface{ |
|
| 221 | 221 | return $this->field($name, 'TINYTEXT', null, null, null, !is_null($defaultValue) ? false : $isNull, !is_null($defaultValue) ? 'USER_DEFINED' : null, $defaultValue); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
| 225 | - public function text(string $name, int $defaultValue = null , bool $isNull = true):CreateTableInterface{ |
|
| 225 | + public function text(string $name, int $defaultValue = null, bool $isNull = true):CreateTableInterface{ |
|
| 226 | 226 | return $this->field($name, 'TEXT', null, null, null, !is_null($defaultValue) ? false : $isNull, !is_null($defaultValue) ? 'USER_DEFINED' : null, $defaultValue); |
| 227 | 227 | } |
| 228 | 228 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @return \chillerlan\Database\Query\CreateTableInterface |
| 237 | 237 | */ |
| 238 | - public function enum(string $name, array $values, $defaultValue = null , bool $isNull = null):CreateTableInterface{ |
|
| 238 | + public function enum(string $name, array $values, $defaultValue = null, bool $isNull = null):CreateTableInterface{ |
|
| 239 | 239 | |
| 240 | 240 | $field = $this->quote($name); |
| 241 | 241 | $field .= 'ENUM (\''.implode('\', \'', $values).'\')'; |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if(in_array($defaultValue, $values, true)){ |
| 248 | - $field .= 'DEFAULT '.(is_int($defaultValue) || is_float($defaultValue) ? $defaultValue : '\''.$defaultValue.'\'') ; |
|
| 248 | + $field .= 'DEFAULT '.(is_int($defaultValue) || is_float($defaultValue) ? $defaultValue : '\''.$defaultValue.'\''); |
|
| 249 | 249 | } |
| 250 | 250 | elseif($isNull && strtolower($defaultValue) === 'null'){ |
| 251 | 251 | $field .= 'DEFAULT NULL'; |