25
25
*/
26
26
class CreateTable extends Statement implements Query, IfNotExists{
27
27
28
- protected bool $ temp = false ;
29
- protected string |null $ primaryKey = null ;
30
- protected array $ cols = [];
31
- protected string |null $ dir = null ;
28
+ protected bool $ temp = false ;
29
+ protected string |null $ primaryKey = null ;
30
+ protected array $ cols = [];
31
+ protected string |null $ dir = null ;
32
32
33
33
public function name (string $ name ):static {
34
34
return $ this ->setName ($ name );
@@ -42,7 +42,6 @@ public function ifNotExists():static{
42
42
return $ this ->setIfNotExists ();
43
43
}
44
44
45
- /** @inheritdoc */
46
45
protected function getSQL ():array {
47
46
return $ this ->dialect ->createTable ($ this ->name , $ this ->cols , $ this ->primaryKey , $ this ->ifNotExists , $ this ->temp , $ this ->dir );
48
47
}
@@ -60,7 +59,17 @@ public function primaryKey(string $field, string|null $dir = null):static{
60
59
return $ this ;
61
60
}
62
61
63
- public function field (string $ name , string $ type , mixed $ length = null , string |null $ attribute = null , string |null $ collation = null , bool |null $ isNull = null , string |null $ defaultType = null , mixed $ defaultValue = null , string |null $ extra = null ):static {
62
+ public function field (
63
+ string $ name ,
64
+ string $ type ,
65
+ mixed $ length = null ,
66
+ string |null $ attribute = null ,
67
+ string |null $ collation = null ,
68
+ bool |null $ isNull = null ,
69
+ string |null $ defaultType = null ,
70
+ mixed $ defaultValue = null ,
71
+ string |null $ extra = null ,
72
+ ):static {
64
73
65
74
if (is_scalar ($ defaultValue ) && $ defaultType === null ){
66
75
$ defaultType = 'USER_DEFINED ' ;
@@ -78,39 +87,39 @@ public function enum(string $name, array $values, mixed $defaultValue = null, bo
78
87
}
79
88
80
89
public function tinyint (string $ name , int |null $ length = null , mixed $ defaultValue = null , bool |null $ isNull = null , string |null $ attribute = null ):static {
81
- return $ this ->field ($ name , 'TINYINT ' , $ length , $ attribute , null , $ isNull , null , $ defaultValue );
90
+ return $ this ->field (name: $ name , type: 'TINYINT ' , length: $ length , attribute: $ attribute , isNull: $ isNull , defaultValue: $ defaultValue );
82
91
}
83
92
84
93
public function int (string $ name , int |null $ length = null , mixed $ defaultValue = null , bool |null $ isNull = null , string |null $ attribute = null ):static {
85
- return $ this ->field ($ name , 'INT ' , $ length , $ attribute , null , $ isNull , null , $ defaultValue );
94
+ return $ this ->field (name: $ name , type: 'INT ' , length: $ length , attribute: $ attribute , isNull: $ isNull , defaultValue: $ defaultValue );
86
95
}
87
96
88
97
public function bigint (string $ name , int |null $ length = null , mixed $ defaultValue = null , bool |null $ isNull = null , string |null $ attribute = null ):static {
89
- return $ this ->field ($ name , 'BIGINT ' , $ length , $ attribute , null , $ isNull , null , $ defaultValue );
98
+ return $ this ->field (name: $ name , type: 'BIGINT ' , length: $ length , attribute: $ attribute , isNull: $ isNull , defaultValue: $ defaultValue );
90
99
}
91
100
92
101
public function varchar (string $ name , int $ length , mixed $ defaultValue = null , bool |null $ isNull = null ):static {
93
- return $ this ->field ($ name , 'VARCHAR ' , $ length , null , null , $ isNull , null , $ defaultValue );
102
+ return $ this ->field (name: $ name , type: 'VARCHAR ' , length: $ length , isNull: $ isNull , defaultValue: $ defaultValue );
94
103
}
95
104
96
105
public function decimal (string $ name , string $ length , mixed $ defaultValue = null , bool |null $ isNull = null ):static {
97
- return $ this ->field ($ name , 'DECIMAL ' , $ length , null , null , $ isNull , null , $ defaultValue );
106
+ return $ this ->field (name: $ name , type: 'DECIMAL ' , length: $ length , isNull: $ isNull , defaultValue: $ defaultValue );
98
107
}
99
108
100
109
public function tinytext (string $ name , mixed $ defaultValue = null , bool |null $ isNull = null ):static {
101
- return $ this ->field ($ name , 'TINYTEXT ' , null , null , null , $ isNull , null , $ defaultValue );
110
+ return $ this ->field (name: $ name , type: 'TINYTEXT ' , isNull: $ isNull , defaultValue: $ defaultValue );
102
111
}
103
112
104
113
public function text (string $ name , mixed $ defaultValue = null , bool |null $ isNull = null ):static {
105
- return $ this ->field ($ name , 'TEXT ' , null , null , null , $ isNull , null , $ defaultValue );
114
+ return $ this ->field (name: $ name , type: 'TEXT ' , isNull: $ isNull , defaultValue: $ defaultValue );
106
115
}
107
116
108
117
public function mediumtext (string $ name , mixed $ defaultValue = null , bool |null $ isNull = null ):static {
109
- return $ this ->field ($ name , 'MEDIUMTEXT ' , null , null , null , $ isNull , null , $ defaultValue );
118
+ return $ this ->field (name: $ name , type: 'MEDIUMTEXT ' , isNull: $ isNull , defaultValue: $ defaultValue );
110
119
}
111
120
112
121
public function longtext (string $ name , mixed $ defaultValue = null , bool |null $ isNull = null ):static {
113
- return $ this ->field ($ name , 'LONGTEXT ' , null , null , null , $ isNull , null , $ defaultValue );
122
+ return $ this ->field (name: $ name , type: 'LONGTEXT ' , isNull: $ isNull , defaultValue: $ defaultValue );
114
123
}
115
124
116
125
}
0 commit comments