@@ -10,16 +10,16 @@ discard block |
||
10 | 10 | * @param $name |
11 | 11 | * @return string |
12 | 12 | */ |
13 | - protected function getNullableValue($nullable,$name) |
|
13 | + protected function getNullableValue($nullable, $name) |
|
14 | 14 | { |
15 | - $nullableValue=''; |
|
15 | + $nullableValue = ''; |
|
16 | 16 | |
17 | - if(isset($nullable[$name])){ |
|
18 | - if($nullable[$name]===false){ |
|
19 | - $nullableValue='NOT NULL'; |
|
17 | + if (isset($nullable[$name])) { |
|
18 | + if ($nullable[$name]===false) { |
|
19 | + $nullableValue = 'NOT NULL'; |
|
20 | 20 | } |
21 | - else{ |
|
22 | - $nullableValue='NULL'; |
|
21 | + else { |
|
22 | + $nullableValue = 'NULL'; |
|
23 | 23 | } |
24 | 24 | } |
25 | 25 | |
@@ -59,22 +59,22 @@ discard block |
||
59 | 59 | */ |
60 | 60 | protected function getValueWithIsset($name) |
61 | 61 | { |
62 | - $nameKey = array_search($name,$this->data['names']); |
|
62 | + $nameKey = array_search($name, $this->data['names']); |
|
63 | 63 | |
64 | 64 | $list = []; |
65 | - $list[] = $this->getNullableValue($this->data['nullable'],$name); |
|
65 | + $list[] = $this->getNullableValue($this->data['nullable'], $name); |
|
66 | 66 | $list[] = (isset($this->data['autoIncrement'][$name])) ? 'AUTO_INCREMENT' : ''; |
67 | 67 | $list[] = (isset($this->data['primaryKey'][$name])) ? 'PRIMARY KEY' : ''; |
68 | 68 | |
69 | - if(isset($this->data['types'][$nameKey])){ |
|
70 | - if($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])){ |
|
69 | + if (isset($this->data['types'][$nameKey])) { |
|
70 | + if ($this->data['types'][$nameKey]=='timestamp' && !isset($this->data['default'][$nameKey])) { |
|
71 | 71 | $this->data['default'][$name] = 'CURRENT_TIMESTAMP'; |
72 | 72 | } |
73 | 73 | |
74 | - if($this->data['types'][$nameKey]!=='timestamp'){ |
|
74 | + if ($this->data['types'][$nameKey]!=='timestamp') { |
|
75 | 75 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
76 | 76 | } |
77 | - else{ |
|
77 | + else { |
|
78 | 78 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
79 | 79 | } |
80 | 80 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | - if(count($list)===3){ |
|
85 | + if (count($list)===3) { |
|
86 | 86 | $list[] = ''; |
87 | 87 | $list[] = ''; |
88 | 88 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | protected function getUniqueValueList($name) |
100 | 100 | { |
101 | 101 | //get unique |
102 | - if(isset($this->data['unique'][$name])){ |
|
103 | - $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
102 | + if (isset($this->data['unique'][$name])) { |
|
103 | + $this->data['uniqueValueList'][] = 'UNIQUE INDEX '.$this->data['unique'][$name]['value'].' ('.$name.' ASC)'; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | protected function getIndexValueList($name) |
111 | 111 | { |
112 | 112 | //get index |
113 | - if(isset($this->data['index'][$name])){ |
|
114 | - $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
113 | + if (isset($this->data['index'][$name])) { |
|
114 | + $this->data['indexValueList'][] = 'INDEX '.$this->data['index'][$name]['value'].' ('.$name.')'; |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected function getCreateDefaultList() |
134 | 134 | { |
135 | - $list = []; |
|
135 | + $list = []; |
|
136 | 136 | |
137 | 137 | foreach ($this->data['names'] as $key=>$name) |
138 | 138 | { |
139 | 139 | list( |
140 | - $nullableValue,$autoIncrementValue, |
|
141 | - $primaryKeyValue,$defaultValue,$commentValue |
|
140 | + $nullableValue, $autoIncrementValue, |
|
141 | + $primaryKeyValue, $defaultValue, $commentValue |
|
142 | 142 | ) = $this->getValueWithIsset($name); |
143 | 143 | |
144 | 144 | //set index values |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | $types = (isset($this->data['types'][$key])) ? $this->data['types'][$key] : ''; |
148 | 148 | |
149 | - $list[]=''.$name.' '.$types.' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
149 | + $list[] = ''.$name.' '.$types.' '.$nullableValue.' '.$defaultValue.' '.$primaryKeyValue.' '.$autoIncrementValue.' '.$commentValue.''; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $list; |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | */ |
158 | 158 | protected function getKeyList() |
159 | 159 | { |
160 | - $keyList = []; |
|
160 | + $keyList = []; |
|
161 | 161 | |
162 | 162 | //multiple indexes |
163 | - if(isset($this->data['index']['indexes'])){ |
|
163 | + if (isset($this->data['index']['indexes'])) { |
|
164 | 164 | |
165 | - foreach ($this->data['index']['indexes'] as $index_key=>$index_value){ |
|
165 | + foreach ($this->data['index']['indexes'] as $index_key=>$index_value) { |
|
166 | 166 | |
167 | 167 | $indexesCommentValue = (isset($index_value['comment'])) ? 'COMMENT "'.$index_value['comment'].'"' : ''; |
168 | 168 | |
169 | 169 | $keyType = (isset($index_value['type'])) ? ucfirst($index_value['type']) : 'KEY'; |
170 | 170 | |
171 | - $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",",$index_value['value']).") ".$indexesCommentValue; |
|
171 | + $keyList[] = "".$keyType." ".$index_value['name']." (".implode(",", $index_value['value']).") ".$indexesCommentValue; |
|
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | { |
184 | 184 | $list = []; |
185 | 185 | |
186 | - foreach ($reference as $constraint=>$values){ |
|
186 | + foreach ($reference as $constraint=>$values) { |
|
187 | 187 | |
188 | - $list[]=',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
188 | + $list[] = ',CONSTRAINT '.$constraint.' FOREIGN KEY ('.$values['key'].') |
|
189 | 189 | REFERENCES '.$values['references']['table'].'('.$values['references']['field'].') '.$this->getOnProcess($values); |
190 | 190 | } |
191 | 191 | |
192 | - return implode (" ",$list); |
|
192 | + return implode(" ", $list); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function getOnProcess($referenceValue) |
199 | 199 | { |
200 | - if(isset($referenceValue['on']) && isset($referenceValue['onOption'])){ |
|
200 | + if (isset($referenceValue['on']) && isset($referenceValue['onOption'])) { |
|
201 | 201 | return ''.$referenceValue['on'].' '.strtoupper($referenceValue['onOption']).''; |
202 | 202 | } |
203 | 203 |
@@ -17,8 +17,7 @@ discard block |
||
17 | 17 | if(isset($nullable[$name])){ |
18 | 18 | if($nullable[$name]===false){ |
19 | 19 | $nullableValue='NOT NULL'; |
20 | - } |
|
21 | - else{ |
|
20 | + } else{ |
|
22 | 21 | $nullableValue='NULL'; |
23 | 22 | } |
24 | 23 | } |
@@ -73,8 +72,7 @@ discard block |
||
73 | 72 | |
74 | 73 | if($this->data['types'][$nameKey]!=='timestamp'){ |
75 | 74 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT "'.$this->data['default'][$name].'"' : ''; |
76 | - } |
|
77 | - else{ |
|
75 | + } else{ |
|
78 | 76 | $list[] = (isset($this->data['default'][$name])) ? ' DEFAULT '.$this->data['default'][$name].'' : ''; |
79 | 77 | } |
80 | 78 |