Completed
Pull Request — master (#6)
by Kris
02:53
created
lib/Server.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@
 block discarded – undo
143 143
     public function dropDatabase($databaseName, $ifExists = false)
144 144
     {
145 145
         $sql = trim(sprintf('DROP DATABASE %s %s', 
146
-            $ifExists === true ? 'IF EXISTS': '',
146
+            $ifExists === true ? 'IF EXISTS' : '',
147 147
             $this->driver->escape($databaseName)));
148 148
         return $this->driver->prepareAndExecuteSql($sql);
149 149
     }
Please login to merge, or discard this patch.
lib/Table.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     {
93 93
         $query = new Query\Update($this->database->getDriver(), $this->name);
94 94
         foreach ($parameters as $key => $val) {
95
-            $query->setValue($key,  $val);
95
+            $query->setValue($key, $val);
96 96
         }
97 97
         return $query;
98 98
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     {
121 121
         $query = new Query\Insert($this->database->getDriver(), $this->name);
122 122
         foreach ($parameters as $key => $val) {
123
-            $query->setValue($key,  $val);
123
+            $query->setValue($key, $val);
124 124
         }
125 125
         return $query;
126 126
     }
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function rename($newName)
170 170
     {
171 171
        $result = $this->database->renameTable($this->name, $newName);
172
-       if ($result){
172
+       if ($result) {
173 173
             $this->name = $newName;
174 174
         }
175 175
         return $result;
Please login to merge, or discard this patch.
lib/Query/InsertBase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     protected function getArgName($column)
65 65
     {
66
-         return '_' . str_replace('.', '_', $column);
66
+         return '_'.str_replace('.', '_', $column);
67 67
     }
68 68
 
69 69
     /**
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     {
79 79
         // Define column parameters
80 80
         $columns = func_get_args();
81
-        if (!empty($columns)){
81
+        if (!empty($columns)) {
82 82
 
83 83
             // clear current parameters
84 84
             unset($this->parameters);
Please login to merge, or discard this patch.
lib/Query/CreateTable.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -148,50 +148,50 @@  discard block
 block discarded – undo
148 148
     private function sqlColumns()
149 149
     {
150 150
         $result = array();
151
-        foreach ($this->columns as $col){
151
+        foreach ($this->columns as $col) {
152 152
 
153 153
             // Parse arguments. First item is NAME and second is TYPE
154 154
             $sqlName   = $this->escape($col[0]);
155
-            $sqlType   = $col[1];  //TODO check type
155
+            $sqlType   = $col[1]; //TODO check type
156 156
             
157 157
             // following arguments
158
-            $args       = array_slice($col, 2);
158
+            $args = array_slice($col, 2);
159 159
             $currentIndex       = 0;
160 160
             $defaultValueIndex  = -1;
161 161
 
162
-            $sqlConstraintUnique    = '';       // UNIQUE ?, not by default
163
-            $sqlConstraintNullable  = 'NULL';   // allow null value by default
164
-            $isPk                   = false;    // PRIMARY KEY?
165
-            $sqlDefault             = '';       // DEFAULT VALUE?
162
+            $sqlConstraintUnique    = ''; // UNIQUE ?, not by default
163
+            $sqlConstraintNullable  = 'NULL'; // allow null value by default
164
+            $isPk                   = false; // PRIMARY KEY?
165
+            $sqlDefault             = ''; // DEFAULT VALUE?
166 166
 
167
-            foreach ($args as $arg){
167
+            foreach ($args as $arg) {
168 168
 
169 169
                 // last index was DEFAULT, so the current argument 
170 170
                 // is the value for default contsaint
171
-                if ($currentIndex === $defaultValueIndex){
171
+                if ($currentIndex === $defaultValueIndex) {
172 172
                     
173 173
                     // string
174
-                    if (is_string($arg)){
174
+                    if (is_string($arg)) {
175 175
                             
176 176
                         // escape everything except constants
177
-                        if (in_array(strtoupper($arg), $this->supportedDefaults)){
178
-                            $sqlDefault = 'DEFAULT ' . $arg;
177
+                        if (in_array(strtoupper($arg), $this->supportedDefaults)) {
178
+                            $sqlDefault = 'DEFAULT '.$arg;
179 179
                         } else {
180
-                            $sqlDefault = 'DEFAULT ' . $this->driver->escapeValue($arg);
180
+                            $sqlDefault = 'DEFAULT '.$this->driver->escapeValue($arg);
181 181
                         }
182 182
                         
183 183
                     // int/float are not escaped
184
-                    } elseif (is_int($arg) || is_float($arg)){
185
-                        $sqlDefault = 'DEFAULT ' . $arg;
184
+                    } elseif (is_int($arg) || is_float($arg)) {
185
+                        $sqlDefault = 'DEFAULT '.$arg;
186 186
 
187 187
                     // bool Type
188
-                    } elseif (is_bool($arg)){
189
-                        $sqlDefault = 'DEFAULT ' . ($arg ? 'TRUE' : 'FALSE');                            
188
+                    } elseif (is_bool($arg)) {
189
+                        $sqlDefault = 'DEFAULT '.($arg ? 'TRUE' : 'FALSE');                            
190 190
                     }
191 191
 
192 192
 
193 193
                 } else {
194
-                    switch (strtoupper($arg)){
194
+                    switch (strtoupper($arg)) {
195 195
                         
196 196
                         // NULL  /NOT NULL 
197 197
                         case 'NULL':
@@ -225,14 +225,14 @@  discard block
 block discarded – undo
225 225
                         // DEFAULT
226 226
                         case 'DEFAULT':
227 227
                             // define next index as the DefaultValue index
228
-                            $defaultValueIndex = $currentIndex +1;
228
+                            $defaultValueIndex = $currentIndex+1;
229 229
                             break;
230 230
                     
231 231
                     }
232 232
                 }
233 233
 
234 234
                 // update  current index
235
-                $currentIndex ++;
235
+                $currentIndex++;
236 236
             }
237 237
 
238 238
             // set optional params
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
         }
248 248
 
249 249
         // FK CONSTRANT
250
-        foreach ($this->foreignKeys as $foreignKey){
251
-            $result[] =  trim(sprintf('CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)', 
250
+        foreach ($this->foreignKeys as $foreignKey) {
251
+            $result[] = trim(sprintf('CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s(%s)', 
252 252
                             $foreignKey['name'], 
253 253
                             $this->driver->escapeIdentifier($foreignKey['src_column']), 
254 254
                             $this->driver->escapeIdentifier($foreignKey['ref_table']),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     public function sql()
269 269
     {
270 270
         $sqlTableName = $this->driver->escape($this->tableName);
271
-        $sqlIfNotExists =  $this->isNotExists === true ? 'IF NOT EXISTS' : '';
271
+        $sqlIfNotExists = $this->isNotExists === true ? 'IF NOT EXISTS' : '';
272 272
 
273 273
         return trim(sprintf(
274 274
             'CREATE TABLE %s %s (%s) %s',
Please login to merge, or discard this patch.
lib/Query/Insert.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
         foreach ($this->parameters as $key => $val) {
47 47
             $arg = $this->getArgName($key);
48 48
             $columnsNames[]    = $this->escape($key); 
49
-            $columnsValues[]   = ':' . $arg;
49
+            $columnsValues[]   = ':'.$arg;
50 50
         }        
51 51
         return trim(sprintf(
52 52
             'INSERT INTO %s (%s) VALUES (%s)',
Please login to merge, or discard this patch.
lib/Query/Delete.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
      */
65 65
     public function where()
66 66
     {
67
-        if (!isset($this->where)){
67
+        if (!isset($this->where)) {
68 68
             $this->where = new Query\Where($this, $this->driver);
69 69
         }
70 70
         return $this->where; 
Please login to merge, or discard this patch.
lib/Query/QueryBase.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@
 block discarded – undo
58 58
      */
59 59
     public function errorCode()
60 60
     {
61
-        return !empty($this->error) ? $this->error['code']: null;
61
+        return !empty($this->error) ? $this->error['code'] : null;
62 62
     }
63 63
 
64 64
     /**
Please login to merge, or discard this patch.
lib/Query/Having.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
      */
54 54
     public function fn($function, $column, $operator, $value)
55 55
     {
56
-        $sql = $function .'('. ($column ? $this->query->escape($column): '') . ') ' . $operator . ' ';
56
+        $sql = $function.'('.($column ? $this->query->escape($column) : '').') '.$operator.' ';
57 57
         $this->addCondition($function, $sql, $column, $value);
58 58
         return $this->returnFunction();
59 59
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      */
70 70
     public function count($operator, $value)
71 71
     {
72
-        $sql = 'COUNT(*) '. $operator. ' ';
72
+        $sql = 'COUNT(*) '.$operator.' ';
73 73
         $this->addCondition('COUNT', $sql, 'COUNT', $value);
74 74
         return $this->returnFunction();
75 75
     }
Please login to merge, or discard this patch.
lib/Query/SelectBase.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         $this->topQuery = $query;
121 121
 
122 122
         // columns arguments
123
-        if (! empty($args)) {
123
+        if (!empty($args)) {
124 124
             $this->parseColumnsArguments($args);
125 125
         }
126 126
     }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         $cols = (count($args) === 1 && is_array($args[0])) ? $args[0] : $args;
140 140
 
141 141
         // parse column
142
-        foreach ($cols as $key => $value){
142
+        foreach ($cols as $key => $value) {
143 143
             
144 144
             // Each arg could be a non indexed array of name, or 
145 145
             // an indexed array name => alias
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      */
374 374
     public function where()
375 375
     {
376
-        if (!isset($this->where)){
376
+        if (!isset($this->where)) {
377 377
             $this->where = new Query\Where($this, $this->driver, $this->topQuery);
378 378
         }
379 379
         return $this->where; 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
      */
401 401
     public function having()
402 402
     {
403
-        if (!isset($this->having)){
403
+        if (!isset($this->having)) {
404 404
             $this->having = new Query\Having($this, $this->driver, $this->topQuery);
405 405
         }
406 406
         return $this->having; 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
      */
488 488
     public function limit($value)
489 489
     {
490
-        if (! is_null($value)) {
490
+        if (!is_null($value)) {
491 491
             $this->limit = (int) $value;
492 492
         }
493 493
         return $this;
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
      */
504 504
     public function offset($value)
505 505
     {
506
-        if (! is_null($value)) {
506
+        if (!is_null($value)) {
507 507
             $this->offset = (int) $value;
508 508
         }
509 509
         return $this;
Please login to merge, or discard this patch.