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