Completed
Push — master ( ace200...1d2086 )
by Daniel
03:32
created
source/FKchange.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     {
67 67
         $sReturn             = [];
68 68
         $targetTableTextFlds = $this->getForeignKeys($elToModify);
69
-        $sReturn[]           = '<div class="tabbertab' . ($tParams ? ' tabbertabdefault' : '')
69
+        $sReturn[]           = '<div class="tabbertab'.($tParams ? ' tabbertabdefault' : '')
70 70
                 . '" id="FKscaleMySQLresults" title="Results">';
71 71
         if (is_array($targetTableTextFlds)) {
72 72
             $sReturn[]    = $this->createDropForeignKeysAndGetTargetColumnDefinition($targetTableTextFlds);
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                 'style'                => 'color:blue;font-weight:bold;',
76 76
                 'includeOldColumnType' => true,
77 77
             ]);
78
-            $sReturn[]    = $this->recreateFKs($elToModify, $targetTableTextFlds);
78
+            $sReturn[] = $this->recreateFKs($elToModify, $targetTableTextFlds);
79 79
         } elseif (!is_array($targetTableTextFlds)) {
80 80
             $sReturn[] = $this->returnMessagesInCaseOfNoResults($mConnection);
81 81
         }
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
 
87 87
     private function createChangeColumn($params, $adtnlFeatures = null)
88 88
     {
89
-        return '<div style="' . (isset($adtnlFeatures['style']) ? $adtnlFeatures['style'] : 'color:blue;') . '">'
90
-                . 'ALTER TABLE `' . $params['Database'] . '`.`' . $params['Table'] . '` '
91
-                . 'CHANGE `' . $params['Column'] . '` `' . $params['Column'] . '` ' . $params['NewDataType'] . ' '
92
-                . $this->setColumnDefinition($params) . ';'
93
-                . (isset($adtnlFeatures['includeOldColumnType']) ? ' /* from ' . $params['OldDataType'] . ' */' : '')
89
+        return '<div style="'.(isset($adtnlFeatures['style']) ? $adtnlFeatures['style'] : 'color:blue;').'">'
90
+                . 'ALTER TABLE `'.$params['Database'].'`.`'.$params['Table'].'` '
91
+                . 'CHANGE `'.$params['Column'].'` `'.$params['Column'].'` '.$params['NewDataType'].' '
92
+                . $this->setColumnDefinition($params).';'
93
+                . (isset($adtnlFeatures['includeOldColumnType']) ? ' /* from '.$params['OldDataType'].' */' : '')
94 94
                 . '</div>';
95 95
     }
96 96
 
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
     private function createDropForeignKey($parameters)
113 113
     {
114 114
         return '<div style="color:red;">'
115
-                . 'ALTER TABLE `' . $parameters['Database'] . '`.`' . $parameters['Table']
116
-                . '` DROP FOREIGN KEY `' . $parameters['ForeignKeyName'] . '`;'
115
+                . 'ALTER TABLE `'.$parameters['Database'].'`.`'.$parameters['Table']
116
+                . '` DROP FOREIGN KEY `'.$parameters['ForeignKeyName'].'`;'
117 117
                 . '</div>';
118 118
     }
119 119
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $sReturn = [];
123 123
         foreach ($targetTableTextFlds as $key => $value) {
124
-            $sReturn[]                                    = $this->createDropForeignKey([
124
+            $sReturn[] = $this->createDropForeignKey([
125 125
                 'Database'       => $value['TABLE_SCHEMA'],
126 126
                 'Table'          => $value['TABLE_NAME'],
127 127
                 'ForeignKeyName' => $value['CONSTRAINT_NAME'],
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
     private function createForeignKey($params)
139 139
     {
140 140
         return '<div style="color:green;">'
141
-                . 'ALTER TABLE `' . $params['Database'] . '`.`' . $params['Table'] . '` '
142
-                . 'ADD CONSTRAINT `' . $params['ForeignKeyName'] . '` '
143
-                . 'FOREIGN KEY (`' . $params['Column'] . '`) REFERENCES `' . $params['ReferencedDatabase'] . '`.`'
144
-                . $params['ReferencedTable'] . '` (`' . $params['ReferencedColumn'] . '`) '
145
-                . 'ON DELETE ' . ($params['RuleDelete'] == 'NULL' ? 'SET NULL' : $params['RuleDelete']) . ' '
146
-                . 'ON UPDATE ' . ($params['RuleUpdate'] == 'NULL' ? 'SET NULL' : $params['RuleUpdate']) . ';'
141
+                . 'ALTER TABLE `'.$params['Database'].'`.`'.$params['Table'].'` '
142
+                . 'ADD CONSTRAINT `'.$params['ForeignKeyName'].'` '
143
+                . 'FOREIGN KEY (`'.$params['Column'].'`) REFERENCES `'.$params['ReferencedDatabase'].'`.`'
144
+                . $params['ReferencedTable'].'` (`'.$params['ReferencedColumn'].'`) '
145
+                . 'ON DELETE '.($params['RuleDelete'] == 'NULL' ? 'SET NULL' : $params['RuleDelete']).' '
146
+                . 'ON UPDATE '.($params['RuleUpdate'] == 'NULL' ? 'SET NULL' : $params['RuleUpdate']).';'
147 147
                 . '</div>';
148 148
     }
149 149
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             'REFERENCED_COLUMN_NAME'  => $elToModify['Column'],
172 172
             'REFERENCED_TABLE_NAME'   => 'NOT NULL',
173 173
         ];
174
-        $query              = $this->sQueryMySqlIndexes($additionalFeatures);
174
+        $query = $this->sQueryMySqlIndexes($additionalFeatures);
175 175
         return $this->setMySQLquery2Server($query, 'full_array_key_numbered')['result'];
176 176
     }
177 177
 
@@ -182,12 +182,12 @@  discard block
 block discarded – undo
182 182
             'TABLE_NAME'   => $elToModify['Table'],
183 183
             'COLUMN_NAME'  => $elToModify['Column'],
184 184
         ];
185
-        $col           = $this->getMySQLlistColumns($colToIdentify);
185
+        $col = $this->getMySQLlistColumns($colToIdentify);
186 186
         return [
187 187
             'Database'       => $targetTableTextFlds[0]['REFERENCED_TABLE_SCHEMA'],
188 188
             'Table'          => $targetTableTextFlds[0]['REFERENCED_TABLE_NAME'],
189 189
             'Column'         => $targetTableTextFlds[0]['REFERENCED_COLUMN_NAME'],
190
-            'OldDataType'    => strtoupper($col[0]['COLUMN_TYPE']) . ' ' . $this->setColumnDefinition($col[0]),
190
+            'OldDataType'    => strtoupper($col[0]['COLUMN_TYPE']).' '.$this->setColumnDefinition($col[0]),
191 191
             'NewDataType'    => $elToModify['NewDataType'],
192 192
             'IS_NULLABLE'    => $col[0]['IS_NULLABLE'],
193 193
             'COLUMN_DEFAULT' => $col[0]['COLUMN_DEFAULT'],
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
             $colDefinition .= ' AUTO_INCREMENT';
214 214
         }
215 215
         if (strlen($inArray['COLUMN_COMMENT']) > 0) {
216
-            $colDefinition .= ' COMMENT "' . $inArray['COLUMN_COMMENT'] . '"';
216
+            $colDefinition .= ' COMMENT "'.$inArray['COLUMN_COMMENT'].'"';
217 217
         }
218 218
         return $colDefinition;
219 219
     }
220 220
 
221 221
     private function setColumnDefinitionPrefix($nullableYesNo, $defaultValue)
222 222
     {
223
-        $colDefinition = 'NOT NULL DEFAULT "' . $defaultValue . '"';
223
+        $colDefinition = 'NOT NULL DEFAULT "'.$defaultValue.'"';
224 224
         if (is_null($defaultValue)) {
225 225
             $colDefinition = 'NOT NULL';
226 226
         }
227 227
         if ($nullableYesNo == 'YES') {
228
-            $colDefinition = 'DEFAULT "' . $defaultValue . '"';
228
+            $colDefinition = 'DEFAULT "'.$defaultValue.'"';
229 229
             if ($defaultValue === null) {
230 230
                 $colDefinition = 'DEFAULT NULL';
231 231
             }
Please login to merge, or discard this patch.