Completed
Push — master ( 5af230...8b8c93 )
by Daniel
02:29
created
source/MySQLiByDanielGPqueries.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     private function sGlueFilterValIntoWhereStr($filterValue)
67 67
     {
68 68
         if (is_array($filterValue)) {
69
-            return 'IN ("' . implode('", "', $filterValue) . '")';
69
+            return 'IN ("'.implode('", "', $filterValue).'")';
70 70
         }
71 71
         return $this->sGlueFilterValueIntoWhereStringFinal($filterValue);
72 72
     }
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
             'NOT NULL|NULL',
80 80
         ];
81 81
         if (in_array($filterValue, explode('|', $kFields[0]))) {
82
-            return '= ' . $filterValue;
82
+            return '= '.$filterValue;
83 83
         } elseif (in_array($filterValue, explode('|', $kFields[1]))) {
84 84
             return $filterValue;
85 85
         } elseif (in_array($filterValue, explode('|', $kFields[2]))) {
86
-            return 'IS ' . $filterValue;
86
+            return 'IS '.$filterValue;
87 87
         }
88
-        return '= "' . $filterValue . '"';
88
+        return '= "'.$filterValue.'"';
89 89
     }
90 90
 
91 91
     /**
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     private function sGlueFiltersIntoWhereArrayFilter($filters)
98 98
     {
99
-        return '(' . implode(') AND (', $filters) . ')';
99
+        return '('.implode(') AND (', $filters).')';
100 100
     }
101 101
 
102 102
     /**
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         if (is_array($filterArray)) {
116 116
             unset($filterArray['LIMIT']);
117 117
             foreach ($filterArray as $key => $value) {
118
-                $fltr[] = '`' . $tableToApplyFilterTo . '`.`' . $key . '` ' . $this->sGlueFilterValIntoWhereStr($value);
118
+                $fltr[] = '`'.$tableToApplyFilterTo.'`.`'.$key.'` '.$this->sGlueFilterValIntoWhereStr($value);
119 119
             }
120 120
         }
121 121
         return $this->sManageDynamicFiltersFinal($fltr);
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     {
126 126
         if (count($filters) > 0) {
127 127
             $sReturn = ['WHERE', $this->sGlueFiltersIntoWhereArrayFilter($filters)];
128
-            return implode(' ', $sReturn) . ' ';
128
+            return implode(' ', $sReturn).' ';
129 129
         }
130 130
         return '';
131 131
     }
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
     {
146 146
         return 'SELECT '
147 147
                 . '`C`.`TABLE_SCHEMA`, '
148
-                . $this->sQueryMySqlColumnsColumns() . ' '
148
+                . $this->sQueryMySqlColumnsColumns().' '
149 149
                 . 'FROM `information_schema`.`COLUMNS` `C` '
150
-                . 'LEFT JOIN `information_schema`.`KEY_COLUMN_USAGE` `KCU` ON ((' . implode(') AND (', [
150
+                . 'LEFT JOIN `information_schema`.`KEY_COLUMN_USAGE` `KCU` ON (('.implode(') AND (', [
151 151
                     '`C`.`TABLE_SCHEMA` = `KCU`.`TABLE_SCHEMA`',
152 152
                     '`C`.`TABLE_NAME` = `KCU`.`TABLE_NAME`',
153 153
                     '`C`.`COLUMN_NAME` = `KCU`.`COLUMN_NAME`',
154
-                ]) . ')) '
154
+                ]).')) '
155 155
                 . $this->sManageDynamicFilters($filterArray, 'C')
156 156
                 . 'GROUP BY `C`.`TABLE_SCHEMA`, `C`.`TABLE_NAME`, `C`.`COLUMN_NAME` '
157 157
                 . 'ORDER BY `C`.`TABLE_SCHEMA`, `C`.`TABLE_NAME`, `C`.`ORDINAL_POSITION` '
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
     {
179 179
         return 'SELECT '
180 180
                 . '`KCU`.`CONSTRAINT_SCHEMA`, '
181
-                . $this->sQueryMySqlIndexesColumns() . ' '
181
+                . $this->sQueryMySqlIndexesColumns().' '
182 182
                 . 'FROM `information_schema`.`KEY_COLUMN_USAGE` `KCU` '
183
-                . 'INNER JOIN `information_schema`.`COLUMNS` `C` ON ((' . implode(') AND (', [
183
+                . 'INNER JOIN `information_schema`.`COLUMNS` `C` ON (('.implode(') AND (', [
184 184
                     '`C`.`TABLE_SCHEMA` = `KCU`.`TABLE_SCHEMA`',
185 185
                     '`C`.`TABLE_NAME` = `KCU`.`TABLE_NAME`',
186 186
                     '`C`.`COLUMN_NAME` = `KCU`.`COLUMN_NAME`',
187
-                ]) . ')) '
188
-                . 'LEFT JOIN `information_schema`.`REFERENTIAL_CONSTRAINTS` `RC` ON ((' . implode(') AND (', [
187
+                ]).')) '
188
+                . 'LEFT JOIN `information_schema`.`REFERENTIAL_CONSTRAINTS` `RC` ON (('.implode(') AND (', [
189 189
                     '`KCU`.`CONSTRAINT_SCHEMA` = `RC`.`CONSTRAINT_SCHEMA`',
190 190
                     '`KCU`.`CONSTRAINT_NAME` = `RC`.`CONSTRAINT_NAME`',
191
-                ]) . ')) '
191
+                ]).')) '
192 192
                 . $this->sManageDynamicFilters($filterArray, 'KCU')
193 193
                 . 'ORDER BY `KCU`.`TABLE_SCHEMA`, `KCU`.`TABLE_NAME`'
194
-                . $this->xtraSoring($filterArray, 'COLUMN_NAME') . ';';
194
+                . $this->xtraSoring($filterArray, 'COLUMN_NAME').';';
195 195
     }
196 196
 
197 197
     private function sQueryMySqlIndexesColumns()
@@ -206,23 +206,23 @@  discard block
 block discarded – undo
206 206
     private function sQueryMySqlStatisticPattern($tblName, $lnkDbCol, $adtnlCol = null, $adtnlFltr = null)
207 207
     {
208 208
         $tblAls = substr($tblName, 0, 1);
209
-        return '(SELECT COUNT(*) AS `No. of records` FROM `information_schema`.`' . $tblName . '` `' . $tblAls . '` '
210
-                . 'WHERE (`' . $tblAls . '`.`' . $lnkDbCol . '` = `S`.`SCHEMA_NAME`)'
211
-                . (!is_null($adtnlCol) ? ' AND (`' . $tblAls . '`.`' . $adtnlCol . '` = "' . $adtnlFltr . '")' : '')
212
-                . ') AS `' . ucwords(strtolower((is_null($adtnlCol) ? $tblName : $adtnlFltr))) . '`';
209
+        return '(SELECT COUNT(*) AS `No. of records` FROM `information_schema`.`'.$tblName.'` `'.$tblAls.'` '
210
+                . 'WHERE (`'.$tblAls.'`.`'.$lnkDbCol.'` = `S`.`SCHEMA_NAME`)'
211
+                . (!is_null($adtnlCol) ? ' AND (`'.$tblAls.'`.`'.$adtnlCol.'` = "'.$adtnlFltr.'")' : '')
212
+                . ') AS `'.ucwords(strtolower((is_null($adtnlCol) ? $tblName : $adtnlFltr))).'`';
213 213
     }
214 214
 
215 215
     protected function sQueryMySqlStatistics($filterArray = null)
216 216
     {
217 217
         return 'SELECT '
218 218
                 . '`S`.`SCHEMA_NAME`, '
219
-                . $this->sQueryMySqlStatisticPattern('TABLES', 'TABLE_SCHEMA', 'TABLE_TYPE', 'BASE TABLE') . ', '
220
-                . $this->sQueryMySqlStatisticPattern('TABLES', 'TABLE_SCHEMA', 'TABLE_TYPE', 'VIEW') . ', '
221
-                . $this->sQueryMySqlStatisticPattern('COLUMNS', 'TABLE_SCHEMA') . ', '
222
-                . $this->sQueryMySqlStatisticPattern('TRIGGERS', 'EVENT_OBJECT_SCHEMA') . ', '
223
-                . $this->sQueryMySqlStatisticPattern('ROUTINES', 'ROUTINE_SCHEMA', 'ROUTINE_TYPE', 'Function') . ', '
224
-                . $this->sQueryMySqlStatisticPattern('ROUTINES', 'ROUTINE_SCHEMA', 'ROUTINE_TYPE', 'Procedure') . ', '
225
-                . $this->sQueryMySqlStatisticPattern('EVENTS', 'EVENT_SCHEMA') . ' '
219
+                . $this->sQueryMySqlStatisticPattern('TABLES', 'TABLE_SCHEMA', 'TABLE_TYPE', 'BASE TABLE').', '
220
+                . $this->sQueryMySqlStatisticPattern('TABLES', 'TABLE_SCHEMA', 'TABLE_TYPE', 'VIEW').', '
221
+                . $this->sQueryMySqlStatisticPattern('COLUMNS', 'TABLE_SCHEMA').', '
222
+                . $this->sQueryMySqlStatisticPattern('TRIGGERS', 'EVENT_OBJECT_SCHEMA').', '
223
+                . $this->sQueryMySqlStatisticPattern('ROUTINES', 'ROUTINE_SCHEMA', 'ROUTINE_TYPE', 'Function').', '
224
+                . $this->sQueryMySqlStatisticPattern('ROUTINES', 'ROUTINE_SCHEMA', 'ROUTINE_TYPE', 'Procedure').', '
225
+                . $this->sQueryMySqlStatisticPattern('EVENTS', 'EVENT_SCHEMA').' '
226 226
                 . 'FROM `information_schema`.`SCHEMATA` `S` '
227 227
                 . 'WHERE (`S`.`SCHEMA_NAME` NOT IN ("information_schema", "mysql", "performance_schema", "sys")) '
228 228
                 . str_replace('WHERE', 'AND', $this->sManageDynamicFilters($filterArray, 'S'))
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
                 . ', `T`.`CREATE_OPTIONS`, `T`.`TABLE_COMMENT` '
244 244
                 . 'FROM `information_schema`.`TABLES` `T` '
245 245
                 . $this->sManageDynamicFilters($filterArray, 'T')
246
-                . $this->xtraSoring($filterArray, 'TABLE_SCHEMA') . ';';
246
+                . $this->xtraSoring($filterArray, 'TABLE_SCHEMA').';';
247 247
     }
248 248
 
249 249
     private function xtraSoring($filterArray, $filterValueToDecide)
Please login to merge, or discard this patch.