@@ -32,25 +32,25 @@ discard block |
||
32 | 32 | */ |
33 | 33 | private function addColumn($alterType) |
34 | 34 | { |
35 | - if(isset($alterType['place'])){ |
|
35 | + if (isset($alterType['place'])) { |
|
36 | 36 | |
37 | 37 | |
38 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
39 | - $placeList=$placeKey .' '.$placeValue.''; |
|
38 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
39 | + $placeList = $placeKey.' '.$placeValue.''; |
|
40 | 40 | } |
41 | 41 | |
42 | - $syntax = implode("",$this->syntax); |
|
42 | + $syntax = implode("", $this->syntax); |
|
43 | 43 | |
44 | 44 | $alterSytanx = 'ALTER TABLE '.$this->table.' ADD COLUMN '.$syntax.' '.$placeList; |
45 | 45 | |
46 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
46 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
47 | 47 | |
48 | - if(count($this->alterExtras)){ |
|
49 | - foreach($this->alterExtras as $extra){ |
|
48 | + if (count($this->alterExtras)) { |
|
49 | + foreach ($this->alterExtras as $extra) { |
|
50 | 50 | |
51 | 51 | $extraSyntax = 'ALTER TABLE '.$this->table.' '.$extra.''; |
52 | 52 | |
53 | - $query=$this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
53 | + $query = $this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -74,40 +74,40 @@ discard block |
||
74 | 74 | */ |
75 | 75 | private function change($alterType) |
76 | 76 | { |
77 | - if(isset($alterType['place'])){ |
|
77 | + if (isset($alterType['place'])) { |
|
78 | 78 | |
79 | - foreach ($alterType['place'] as $placeKey=>$placeValue){ |
|
80 | - $placeList=$placeKey .' '.$placeValue.''; |
|
79 | + foreach ($alterType['place'] as $placeKey=>$placeValue) { |
|
80 | + $placeList = $placeKey.' '.$placeValue.''; |
|
81 | 81 | } |
82 | 82 | |
83 | - $syntax = implode("",$this->syntax); |
|
83 | + $syntax = implode("", $this->syntax); |
|
84 | 84 | |
85 | 85 | $columns = $this->schema->getConnection()->showColumnsFrom($this->table); |
86 | 86 | |
87 | - foreach ($columns as $columnKey=>$columnData){ |
|
88 | - if($columnData['Field']==$placeValue){ |
|
87 | + foreach ($columns as $columnKey=>$columnData) { |
|
88 | + if ($columnData['Field']==$placeValue) { |
|
89 | 89 | $changeAbleField = $columns[$columnKey+1]['Field']; |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $syntaxList = explode(' ',$syntax); |
|
93 | + $syntaxList = explode(' ', $syntax); |
|
94 | 94 | |
95 | - if(current($syntaxList)!==$changeAbleField){ |
|
96 | - $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ',array_splice($syntaxList,1)).' '.$placeList; |
|
95 | + if (current($syntaxList)!==$changeAbleField) { |
|
96 | + $alterSytanx = 'ALTER TABLE '.$this->table.' change '.$changeAbleField.' '.current($syntaxList).' '.implode(' ', array_splice($syntaxList, 1)).' '.$placeList; |
|
97 | 97 | } |
98 | - else{ |
|
98 | + else { |
|
99 | 99 | $alterSytanx = 'ALTER TABLE '.$this->table.' modify '.$syntax.' '.$placeList; |
100 | 100 | } |
101 | 101 | |
102 | 102 | |
103 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
103 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
104 | 104 | |
105 | - if(count($this->alterExtras)){ |
|
106 | - foreach($this->alterExtras as $extra){ |
|
105 | + if (count($this->alterExtras)) { |
|
106 | + foreach ($this->alterExtras as $extra) { |
|
107 | 107 | |
108 | 108 | $extraSyntax = 'ALTER TABLE '.$this->table.' '.$extra.''; |
109 | 109 | |
110 | - $query=$this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
110 | + $query = $this->schema->getConnection()->setQueryBasic($extraSyntax); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -129,17 +129,17 @@ discard block |
||
129 | 129 | */ |
130 | 130 | private function addIndex($alterType) |
131 | 131 | { |
132 | - if(isset($this->syntax[0])){ |
|
132 | + if (isset($this->syntax[0])) { |
|
133 | 133 | |
134 | 134 | $index = $this->syntax[0]; |
135 | 135 | |
136 | - foreach($index as $name=>$item){ |
|
136 | + foreach ($index as $name=>$item) { |
|
137 | 137 | $index_name = $name; |
138 | - $indexes = implode(',',$item); |
|
138 | + $indexes = implode(',', $item); |
|
139 | 139 | } |
140 | 140 | $alterSytanx = 'create index '.$index_name.' on '.$this->table.' ('.$indexes.')'; |
141 | 141 | |
142 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
142 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
143 | 143 | |
144 | 144 | return [ |
145 | 145 | 'syntax'=>$this->syntax, |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | */ |
161 | 161 | private function addUnique($alterType) |
162 | 162 | { |
163 | - if(isset($this->syntax[0])){ |
|
163 | + if (isset($this->syntax[0])) { |
|
164 | 164 | |
165 | 165 | $unique = $this->syntax[0]; |
166 | 166 | |
167 | - foreach($unique as $name=>$item){ |
|
167 | + foreach ($unique as $name=>$item) { |
|
168 | 168 | $unique_name = $name; |
169 | - $uniques = implode(',',$item); |
|
169 | + $uniques = implode(',', $item); |
|
170 | 170 | } |
171 | 171 | $alterSytanx = 'ALTER TABLE '.$this->table.' ADD CONSTRAINT '.$unique_name.' UNIQUE ('.$uniques.')'; |
172 | 172 | |
173 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
173 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
174 | 174 | |
175 | 175 | return [ |
176 | 176 | 'syntax'=>$this->syntax, |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | */ |
192 | 192 | private function dropColumn($alterType) |
193 | 193 | { |
194 | - if(isset($this->syntax[0])){ |
|
194 | + if (isset($this->syntax[0])) { |
|
195 | 195 | |
196 | 196 | $column = rtrim($this->syntax[0]); |
197 | 197 | |
198 | 198 | $alterSytanx = 'alter table '.$this->table.' drop column '.$column; |
199 | 199 | |
200 | - $query=$this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
200 | + $query = $this->schema->getConnection()->setQueryBasic($alterSytanx); |
|
201 | 201 | |
202 | 202 | return [ |
203 | 203 | 'syntax'=>$this->syntax, |
@@ -224,32 +224,32 @@ discard block |
||
224 | 224 | |
225 | 225 | $this->getDefaultSyntaxGroup(); |
226 | 226 | |
227 | - $this->syntax[]=')'; |
|
227 | + $this->syntax[] = ')'; |
|
228 | 228 | |
229 | 229 | //get table collation |
230 | - if(isset($this->data['tableCollation']['table'])){ |
|
231 | - $this->syntax[]=' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
230 | + if (isset($this->data['tableCollation']['table'])) { |
|
231 | + $this->syntax[] = ' DEFAULT CHARACTER SET '.$this->data['tableCollation']['table']; |
|
232 | 232 | } |
233 | - else{ |
|
234 | - $this->syntax[]=' DEFAULT CHARACTER SET utf8'; |
|
233 | + else { |
|
234 | + $this->syntax[] = ' DEFAULT CHARACTER SET utf8'; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | //get engine |
238 | - if($this->data['engine']!==null) |
|
238 | + if ($this->data['engine']!==null) |
|
239 | 239 | { |
240 | - $this->syntax[]=' ENGINE='.$this->data['engine'].' '; |
|
240 | + $this->syntax[] = ' ENGINE='.$this->data['engine'].' '; |
|
241 | 241 | } |
242 | - else{ |
|
243 | - $this->syntax[]=' ENGINE=InnoDB '; |
|
242 | + else { |
|
243 | + $this->syntax[] = ' ENGINE=InnoDB '; |
|
244 | 244 | } |
245 | 245 | |
246 | - $syntax = implode("",$this->syntax); |
|
246 | + $syntax = implode("", $this->syntax); |
|
247 | 247 | |
248 | - if(in_array($this->table,$existTables)){ |
|
248 | + if (in_array($this->table, $existTables)) { |
|
249 | 249 | return false; |
250 | 250 | } |
251 | - else{ |
|
252 | - $query=$this->schema->getConnection()->setQueryBasic($syntax); |
|
251 | + else { |
|
252 | + $query = $this->schema->getConnection()->setQueryBasic($syntax); |
|
253 | 253 | |
254 | 254 | return [ |
255 | 255 | 'syntax'=>$syntax, |
@@ -264,48 +264,48 @@ discard block |
||
264 | 264 | /** |
265 | 265 | * @param null $group |
266 | 266 | */ |
267 | - private function getDefaultSyntaxGroup($group=null) |
|
267 | + private function getDefaultSyntaxGroup($group = null) |
|
268 | 268 | { |
269 | - $this->syntax[] = implode(",",$this->getCreateDefaultList()); |
|
269 | + $this->syntax[] = implode(",", $this->getCreateDefaultList()); |
|
270 | 270 | |
271 | 271 | //get unique values |
272 | - if(isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])){ |
|
272 | + if (isset($this->data['uniqueValueList']) && count($this->data['uniqueValueList'])) { |
|
273 | 273 | |
274 | - if($group=='create'){ |
|
275 | - $this->syntax[]=','.implode(',',$this->data['uniqueValueList']); |
|
274 | + if ($group=='create') { |
|
275 | + $this->syntax[] = ','.implode(',', $this->data['uniqueValueList']); |
|
276 | 276 | } |
277 | - else{ |
|
278 | - $this->alterExtras[]='ADD '.implode(',',$this->data['uniqueValueList']); |
|
277 | + else { |
|
278 | + $this->alterExtras[] = 'ADD '.implode(',', $this->data['uniqueValueList']); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | 283 | //get index values |
284 | - if(isset($this->data['indexValueList']) && count($this->data['indexValueList'])){ |
|
284 | + if (isset($this->data['indexValueList']) && count($this->data['indexValueList'])) { |
|
285 | 285 | |
286 | - if($group=='create'){ |
|
287 | - $this->syntax[]=','.implode(',',$this->data['indexValueList']); |
|
286 | + if ($group=='create') { |
|
287 | + $this->syntax[] = ','.implode(',', $this->data['indexValueList']); |
|
288 | 288 | } |
289 | - else{ |
|
290 | - $this->alterExtras[]='ADD '.implode(',',$this->data['indexValueList']); |
|
289 | + else { |
|
290 | + $this->alterExtras[] = 'ADD '.implode(',', $this->data['indexValueList']); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | 295 | //get index values for key |
296 | - if(count($this->getKeyList())){ |
|
297 | - $this->syntax[]=','.implode(',',$this->getKeyList()); |
|
296 | + if (count($this->getKeyList())) { |
|
297 | + $this->syntax[] = ','.implode(',', $this->getKeyList()); |
|
298 | 298 | } |
299 | 299 | |
300 | - if(count($this->data['references'])){ |
|
301 | - $this->syntax[]=$this->getReferenceSyntax($this->data['references']); |
|
300 | + if (count($this->data['references'])) { |
|
301 | + $this->syntax[] = $this->getReferenceSyntax($this->data['references']); |
|
302 | 302 | } |
303 | 303 | |
304 | - if(isset($this->syntax[0]) && $this->syntax[0]=='' && $group=='addIndex'){ |
|
304 | + if (isset($this->syntax[0]) && $this->syntax[0]=='' && $group=='addIndex') { |
|
305 | 305 | $this->syntax[0] = $this->data['index']; |
306 | 306 | } |
307 | 307 | |
308 | - if(isset($this->syntax[0]) && $this->syntax[0]=='' && $group=='addUnique'){ |
|
308 | + if (isset($this->syntax[0]) && $this->syntax[0]=='' && $group=='addUnique') { |
|
309 | 309 | $this->syntax[0] = $this->data['unique']; |
310 | 310 | } |
311 | 311 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @var array |
32 | 32 | */ |
33 | - protected $auto_increment=array(); |
|
33 | + protected $auto_increment = array(); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @var $collation |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | /** |
46 | 46 | * @var array $primaryKey |
47 | 47 | */ |
48 | - protected $primaryKey=array(); |
|
48 | + protected $primaryKey = array(); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @var array $references |
52 | 52 | */ |
53 | - protected $references=array(); |
|
53 | + protected $references = array(); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * @var $schemaType |
@@ -65,17 +65,17 @@ discard block |
||
65 | 65 | /** |
66 | 66 | * @var $name array |
67 | 67 | */ |
68 | - protected $name=array(); |
|
68 | + protected $name = array(); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @var array $nullable |
72 | 72 | */ |
73 | - protected $nullable=array(); |
|
73 | + protected $nullable = array(); |
|
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @var array $types |
77 | 77 | */ |
78 | - protected $types=array(); |
|
78 | + protected $types = array(); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * @var $engine |
@@ -85,17 +85,17 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * @var $default array |
87 | 87 | */ |
88 | - protected $default=array(); |
|
88 | + protected $default = array(); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * @var array $index |
92 | 92 | */ |
93 | - protected $index=array(); |
|
93 | + protected $index = array(); |
|
94 | 94 | |
95 | 95 | /** |
96 | 96 | * @var array $unique |
97 | 97 | */ |
98 | - protected $unique=array(); |
|
98 | + protected $unique = array(); |
|
99 | 99 | |
100 | 100 | /** |
101 | 101 | * @var $table |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public function auto_increment() |
109 | 109 | { |
110 | - if(count($this->auto_increment)==0){ |
|
110 | + if (count($this->auto_increment)==0) { |
|
111 | 111 | |
112 | - if($this->getLastName()===false){ |
|
113 | - $this->name[]='id'; |
|
114 | - $this->setTypes('int',14); |
|
112 | + if ($this->getLastName()===false) { |
|
113 | + $this->name[] = 'id'; |
|
114 | + $this->setTypes('int', 14); |
|
115 | 115 | } |
116 | - $this->auto_increment[$this->getLastName()]=true; |
|
116 | + $this->auto_increment[$this->getLastName()] = true; |
|
117 | 117 | $this->primaryKey(); |
118 | 118 | } |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function comment($value) |
126 | 126 | { |
127 | - $this->comment[$this->getLastName()]=$value; |
|
127 | + $this->comment[$this->getLastName()] = $value; |
|
128 | 128 | |
129 | 129 | return $this; |
130 | 130 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function name($name) |
137 | 137 | { |
138 | - if(in_array($name,$this->name)){ |
|
138 | + if (in_array($name, $this->name)) { |
|
139 | 139 | $this->setError('You have written the '.$name.' name more than 1.'); |
140 | 140 | } |
141 | 141 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | public function default($value) |
153 | 153 | { |
154 | - $this->default[$this->getLastName()]=$value; |
|
154 | + $this->default[$this->getLastName()] = $value; |
|
155 | 155 | |
156 | 156 | return $this; |
157 | 157 | } |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | * @param bool $table |
162 | 162 | * @return $this |
163 | 163 | */ |
164 | - public function collation($value,$table=false) |
|
164 | + public function collation($value, $table = false) |
|
165 | 165 | { |
166 | - if($table===false) |
|
166 | + if ($table===false) |
|
167 | 167 | { |
168 | - $this->collation[$this->getLastName()]=$value; |
|
168 | + $this->collation[$this->getLastName()] = $value; |
|
169 | 169 | } |
170 | - else{ |
|
171 | - $this->collation['table']=$value; |
|
170 | + else { |
|
171 | + $this->collation['table'] = $value; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $this; |
@@ -180,17 +180,17 @@ discard block |
||
180 | 180 | * @param bool $key |
181 | 181 | * @return $this|WizardContract |
182 | 182 | */ |
183 | - public function index($name=null,$value=null,$key=false) |
|
183 | + public function index($name = null, $value = null, $key = false) |
|
184 | 184 | { |
185 | 185 | $name = ($name===null) ? $this->getLastName() : $name; |
186 | 186 | $value = ($value===null) ? $name : $value; |
187 | 187 | |
188 | - if($key===false){ |
|
189 | - $this->index[$this->getLastName()]=['name'=>$name,'value'=>$value]; |
|
188 | + if ($key===false) { |
|
189 | + $this->index[$this->getLastName()] = ['name'=>$name, 'value'=>$value]; |
|
190 | 190 | } |
191 | 191 | |
192 | - if($key===true){ |
|
193 | - $this->index['indexes'][]=['name'=>$name,'value'=>$value]; |
|
192 | + if ($key===true) { |
|
193 | + $this->index['indexes'][] = ['name'=>$name, 'value'=>$value]; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | return $this; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @param array $indexes |
202 | 202 | * @return void |
203 | 203 | */ |
204 | - public function indexes($index_name,$indexes=array()) |
|
204 | + public function indexes($index_name, $indexes = array()) |
|
205 | 205 | { |
206 | 206 | $this->index[$index_name] = $indexes; |
207 | 207 | } |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * @param bool $null |
211 | 211 | * @return $this |
212 | 212 | */ |
213 | - public function nullable($null=true) |
|
213 | + public function nullable($null = true) |
|
214 | 214 | { |
215 | - $this->nullable[$this->getLastName()]=$null; |
|
215 | + $this->nullable[$this->getLastName()] = $null; |
|
216 | 216 | |
217 | 217 | return $this; |
218 | 218 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function primaryKey() |
224 | 224 | { |
225 | - $this->primaryKey[$this->getLastName()]=true; |
|
225 | + $this->primaryKey[$this->getLastName()] = true; |
|
226 | 226 | |
227 | 227 | return $this; |
228 | 228 | } |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | * @param null $value |
241 | 241 | * @return $this|mixed |
242 | 242 | */ |
243 | - public function unique($name=null,$value=null) |
|
243 | + public function unique($name = null, $value = null) |
|
244 | 244 | { |
245 | 245 | $name = ($name===null) ? $this->getLastName() : $name; |
246 | 246 | $value = ($value===null) ? $name : $value; |
247 | 247 | |
248 | - $this->unique[$this->getLastName()] = ['name'=>$name,'value'=>$value]; |
|
248 | + $this->unique[$this->getLastName()] = ['name'=>$name, 'value'=>$value]; |
|
249 | 249 | |
250 | 250 | return $this; |
251 | 251 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @param null $value |
256 | 256 | * @return $this|mixed |
257 | 257 | */ |
258 | - public function uniques($unique_name,$uniques=array()) |
|
258 | + public function uniques($unique_name, $uniques = array()) |
|
259 | 259 | { |
260 | 260 | $this->unique[$unique_name] = $uniques; |
261 | 261 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | private function getWizardAlterInstance($group) |
80 | 80 | { |
81 | - $this->setAlterType('group',$group); |
|
81 | + $this->setAlterType('group', $group); |
|
82 | 82 | |
83 | 83 | return new WizardAlter($this); |
84 | 84 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | private function dropWizardAlterInstance($group) |
91 | 91 | { |
92 | - $this->setAlterType('group',$group); |
|
92 | + $this->setAlterType('group', $group); |
|
93 | 93 | |
94 | 94 | return $this; |
95 | 95 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | private function addIndexWizardAlterInstance($group) |
102 | 102 | { |
103 | - $this->setAlterType('group',$group); |
|
103 | + $this->setAlterType('group', $group); |
|
104 | 104 | |
105 | 105 | return $this; |
106 | 106 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | private function addUniqueWizardAlterInstance($group) |
113 | 113 | { |
114 | - $this->setAlterType('group',$group); |
|
114 | + $this->setAlterType('group', $group); |
|
115 | 115 | |
116 | 116 | return $this; |
117 | 117 | } |
@@ -9,6 +9,6 @@ |
||
9 | 9 | * @param array $uniques |
10 | 10 | * @return mixed |
11 | 11 | */ |
12 | - public function uniques($unique_name,$uniques=array()); |
|
12 | + public function uniques($unique_name, $uniques = array()); |
|
13 | 13 | } |
14 | 14 |
@@ -9,6 +9,6 @@ |
||
9 | 9 | * @param array $indexes |
10 | 10 | * @return mixed |
11 | 11 | */ |
12 | - public function indexes($index_name,$indexes=array()); |
|
12 | + public function indexes($index_name, $indexes = array()); |
|
13 | 13 | } |
14 | 14 |