Completed
Push — master ( b92126...853c09 )
by Christopher
37:17 queued 22:19
created
index.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@
 block discarded – undo
22 22
 // SQLite config example
23 23
 // Replace it in the new Connection call to use SQLite
24 24
 $sqliteConfig = [
25
-	"type" => "sqlite",
26
-	"database" => "test.db"
27
-	];
25
+    "type" => "sqlite",
26
+    "database" => "test.db"
27
+    ];
28 28
 
29 29
 // MySQL config example
30 30
 // makse sure you have a mysql database connection available
Please login to merge, or discard this patch.
src/Connection.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 
78 78
         $db = new mysqli($config['host'], $config['user'], $config['password'], $config['database']);
79 79
 
80
-        if($db->connect_errno > 0){
80
+        if ($db->connect_errno > 0) {
81 81
             die('Unable to connect to database [' . $db->connect_error . ']');
82 82
         }
83 83
 
Please login to merge, or discard this patch.
src/Potato.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@
 block discarded – undo
146 146
 
147 147
         $res = [];
148 148
 
149
-       switch (Connection::$dbType) {
149
+        switch (Connection::$dbType) {
150 150
             case 'sqlite':
151 151
                 $results = Connection::db()->query($query);
152 152
                 while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         if (!$this->tableName)
28 28
         {
29 29
             $ref = new ReflectionClass($this);
30
-            $tableName = strtolower($ref->getShortName()).'s';
30
+            $tableName = strtolower($ref->getShortName()) . 's';
31 31
         }
32 32
 
33 33
         // Test if table exists else throw an exception
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             case 'mysql':
55 55
                 $query = "Select COUNT(*) FROm information_schema.TABLES WHERE TABLE_NAME = '$tableName';"; 
56 56
                 if (!$exists = Connection::db()->query($query)) {
57
-                    echo 'error'.Connection::db()->error;
57
+                    echo 'error' . Connection::db()->error;
58 58
                 } else {
59 59
                     $exists = $exists->num_rows;
60 60
                 }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                 break;
120 120
             case 'mysql':
121 121
                 if ($results = Connection::db()->query($query)) {
122
-                    while($row = $results->fetch_assoc()){
122
+                    while ($row = $results->fetch_assoc()) {
123 123
                         array_push($res, $row);
124 124
                     }
125 125
                 } else {
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
                 break;
156 156
             case 'mysql':
157 157
                 if ($results = Connection::db()->query($query)) {
158
-                    while($row = $results->fetch_assoc()){
158
+                    while ($row = $results->fetch_assoc()) {
159 159
                         array_push($res, $row);
160 160
                     }
161 161
                 } else {
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         if (!empty($res)) {
168 168
             return $res;
169 169
         } else {
170
-            throw new PotatoException('There is no user with id '. $id);
170
+            throw new PotatoException('There is no user with id ' . $id);
171 171
         }
172 172
     }
173 173
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
                 }
188 188
                 break;
189 189
             case 'mysql':
190
-                $query = "SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='".Connection::$dbName."' AND `TABLE_NAME`='$this->tableName';";
190
+                $query = "SELECT `COLUMN_NAME` FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA`='" . Connection::$dbName . "' AND `TABLE_NAME`='$this->tableName';";
191 191
                 if ($results = Connection::db()->query($query)) {
192
-                    while($row = $results->fetch_assoc()){
192
+                    while ($row = $results->fetch_assoc()) {
193 193
                         array_push($columns, $row['COLUMN_NAME']);
194 194
                     }
195 195
                 } else {
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
 
221 221
         if (!self::$id) {
222 222
             // new record so we insert
223
-            $query = "INSERT INTO $this->tableName (".implode(", ", $availableColumnNames).") VALUES('".implode("', '", $availableColumnValues)."');";
223
+            $query = "INSERT INTO $this->tableName (" . implode(", ", $availableColumnNames) . ") VALUES('" . implode("', '", $availableColumnValues) . "');";
224 224
         } else {
225 225
             // existing record, se we update
226 226
             $query = "UPDATE $this->tableName SET ";
227 227
 
228 228
             for ($i = 0; $i < count($availableColumnNames); $i++) {
229 229
                 $prop = $availableColumnNames[$i];
230
-                $query .= " $prop = '". $this->{$prop}."'";
230
+                $query .= " $prop = '" . $this->{$prop} . "'";
231 231
 
232 232
                 if ($i != count($availableColumnNames) - 1) {
233 233
                     $query .= ",";
234 234
                 }
235 235
             }
236 236
 
237
-            $query .= " WHERE id = ".self::$id;
237
+            $query .= " WHERE id = " . self::$id;
238 238
         }
239 239
 
240 240
         $result = Connection::db()->query($query);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
         self::getOne($id);
271 271
 
272
-        $query = "DELETE FROM $table WHERE id = ".$id;
272
+        $query = "DELETE FROM $table WHERE id = " . $id;
273 273
 
274 274
         $result = Connection::db()->query($query);
275 275
     }
Please login to merge, or discard this patch.