1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Migratio\GrammarStructure\Mysql\Wizard; |
4
|
|
|
|
5
|
|
|
class WizardHelper |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* @return mixed |
9
|
|
|
*/ |
10
|
|
|
public function getAutoIncrement() |
11
|
|
|
{ |
12
|
|
|
return $this->auto_increment; |
13
|
|
|
} |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @return mixed |
17
|
|
|
*/ |
18
|
|
|
public function getAlterBinds() |
19
|
|
|
{ |
20
|
|
|
return $this->alterBinds; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @return mixed |
25
|
|
|
*/ |
26
|
|
|
public function getComment() |
27
|
|
|
{ |
28
|
|
|
return $this->comment; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return mixed |
33
|
|
|
*/ |
34
|
|
|
public function getDefault() |
35
|
|
|
{ |
36
|
|
|
return $this->default; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return mixed |
41
|
|
|
*/ |
42
|
|
|
public function getEngine() |
43
|
|
|
{ |
44
|
|
|
return $this->engine; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return mixed |
49
|
|
|
*/ |
50
|
|
|
public function getError() |
51
|
|
|
{ |
52
|
|
|
return $this->error; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getFile() |
56
|
|
|
{ |
57
|
|
|
return $this->file; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return mixed |
62
|
|
|
*/ |
63
|
|
|
public function getIndex() |
64
|
|
|
{ |
65
|
|
|
return $this->index; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return mixed |
70
|
|
|
*/ |
71
|
|
|
public function getNames() |
72
|
|
|
{ |
73
|
|
|
return $this->name; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
|
|
public function getPrimaryKey() |
80
|
|
|
{ |
81
|
|
|
return $this->primaryKey; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return mixed |
86
|
|
|
*/ |
87
|
|
|
public function getReferences() |
88
|
|
|
{ |
89
|
|
|
return $this->references; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @return mixed |
94
|
|
|
*/ |
95
|
|
|
public function getSchemaType() |
96
|
|
|
{ |
97
|
|
|
return $this->schemaType; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @return mixed |
102
|
|
|
*/ |
103
|
|
|
public function getTable() |
104
|
|
|
{ |
105
|
|
|
return $this->table; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @return mixed |
110
|
|
|
*/ |
111
|
|
|
public function getTypes() |
112
|
|
|
{ |
113
|
|
|
return $this->types; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* @return mixed |
118
|
|
|
*/ |
119
|
|
|
public function getUnique() |
120
|
|
|
{ |
121
|
|
|
return $this->unique; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @param $message |
126
|
|
|
*/ |
127
|
|
|
public function setError($message) |
128
|
|
|
{ |
129
|
|
|
$this->error[]=$message; |
|
|
|
|
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param $engine |
134
|
|
|
*/ |
135
|
|
|
public function setEngine($engine) |
136
|
|
|
{ |
137
|
|
|
$this->engine=$engine; |
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @param $name |
142
|
|
|
*/ |
143
|
|
|
public function setName($name) |
144
|
|
|
{ |
145
|
|
|
$this->name[]=$name; |
|
|
|
|
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param $file |
150
|
|
|
*/ |
151
|
|
|
public function setFile($file) |
152
|
|
|
{ |
153
|
|
|
$this->file = $file; |
|
|
|
|
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* @param $key |
158
|
|
|
* @param $value |
159
|
|
|
*/ |
160
|
|
|
public function setAlterType($key,$value) |
161
|
|
|
{ |
162
|
|
|
$this->alterType[$key]=$value; |
|
|
|
|
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* @param $table |
167
|
|
|
*/ |
168
|
|
|
public function setTable($table) |
169
|
|
|
{ |
170
|
|
|
$this->table=$table; |
|
|
|
|
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* @param $schemaType |
175
|
|
|
*/ |
176
|
|
|
public function schemaType($schemaType) |
177
|
|
|
{ |
178
|
|
|
$this->schemaType=$schemaType; |
|
|
|
|
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* @param $type |
183
|
|
|
* @param null $value |
|
|
|
|
184
|
|
|
* @param null $cond |
|
|
|
|
185
|
|
|
*/ |
186
|
|
|
public function setTypes($type,$value=null,$cond=null) |
187
|
|
|
{ |
188
|
|
|
if(!is_array($value) && $value!==null){ |
|
|
|
|
189
|
|
|
$this->types[]=''.$type.'('.$value.')'; |
190
|
|
|
} |
191
|
|
|
else{ |
192
|
|
|
|
193
|
|
|
if($cond=='enum'){ |
194
|
|
|
$this->types[]="".$type."('".implode("','",$value)."')"; |
|
|
|
|
195
|
|
|
} |
196
|
|
|
else{ |
197
|
|
|
$this->types[]=''.$type.''; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* @return mixed |
206
|
|
|
*/ |
207
|
|
|
protected function getLastName(){ |
208
|
|
|
|
209
|
|
|
return end($this->name); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
/** |
213
|
|
|
* @param $collation |
214
|
|
|
*/ |
215
|
|
|
public function getCollation() |
216
|
|
|
{ |
217
|
|
|
return $this->collation; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* @return mixed |
222
|
|
|
*/ |
223
|
|
|
public function getNullable() |
224
|
|
|
{ |
225
|
|
|
return $this->nullable; |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
/** |
229
|
|
|
* @param $name |
230
|
|
|
* @param $data |
231
|
|
|
* @param string $specialist |
232
|
|
|
*/ |
233
|
|
|
public function updateIndexesForSpecialist($name,$data,$specialist='type') |
234
|
|
|
{ |
235
|
|
|
$indexes = $this->getIndex(); |
236
|
|
|
|
237
|
|
|
foreach ($indexes['indexes'] as $key=>$index){ |
238
|
|
|
|
239
|
|
|
if($index['name']==$name){ |
240
|
|
|
$this->index['indexes'][$key][$specialist]=$data; |
|
|
|
|
241
|
|
|
} |
242
|
|
|
} |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* @param $constraint |
247
|
|
|
* @param $key |
248
|
|
|
* @param $value |
249
|
|
|
*/ |
250
|
|
|
public function setReferences($constraint,$key,$value) |
251
|
|
|
{ |
252
|
|
|
$this->references[$constraint][$key]=$value; |
|
|
|
|
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* @return mixed |
257
|
|
|
*/ |
258
|
|
|
public function getAlterType() |
259
|
|
|
{ |
260
|
|
|
return $this->alterType; |
261
|
|
|
} |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
|