Passed
Pull Request — master (#5697)
by David
10:07
created
html/inc/db_conn.inc 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,8 @@
 block discarded – undo
33 33
         } else {
34 34
             $port = null;
35 35
         }
36
-        if (1) {        // don't use persistent connections for now
36
+        if (1) {
37
+// don't use persistent connections for now
37 38
             $this->db_conn = @new mysqli(
38 39
                 $host, $user, $passwd, $name, $port
39 40
             );
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
 // Intended to be subclassed (e.g., BoincDb, BossaDb)
23 23
 //
24 24
 class DbConn {
25
-    var $db_conn;       // a mysqli object
26
-    var $db_name;       // the DB name
25
+    var $db_conn; // a mysqli object
26
+    var $db_name; // the DB name
27 27
 
28 28
     function init_conn($user, $passwd, $host, $name) {
29 29
         $x = explode(":", $host);
30
-        if (sizeof($x)>1) {
30
+        if (sizeof($x) > 1) {
31 31
             $host = $x[0];
32 32
             $port = $x[1];
33 33
         } else {
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
             $where_clause = "where $where_clause";
138 138
         }
139 139
         $query = "select $fields from DBNAME.$table $where_clause $order_clause";
140
-        return $this->enum_general($classname,$query);
140
+        return $this->enum_general($classname, $query);
141 141
     }
142 142
 
143
-    function enum($table, $classname, $where_clause=null, $order_clause=null) {
143
+    function enum($table, $classname, $where_clause = null, $order_clause = null) {
144 144
         return self::enum_fields(
145 145
             $table, $classname, '*', $where_clause, $order_clause
146 146
         );
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
         if ($x) return (double)$x->$field;
186 186
         return false;
187 187
     }
188
-    function count($table, $clause="TRUE") {
188
+    function count($table, $clause = "TRUE") {
189 189
         $query = "select count(*) as total from DBNAME.$table where $clause";
190 190
         return $this->get_int($query, 'total');
191 191
     }
192
-    function sum($table, $field, $clause="") {
192
+    function sum($table, $field, $clause = "") {
193 193
         $query = "select sum($field) as total from DBNAME.$table $clause";
194 194
         return $this->get_double($query, 'total');
195 195
     }
196
-    function max($table, $field, $clause="") {
196
+    function max($table, $field, $clause = "") {
197 197
         $query = "select max($field) as total from DBNAME.$table $clause";
198 198
         return $this->get_double($query, 'total');
199 199
     }
Please login to merge, or discard this patch.
html/inc/boinc_db.inc 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 // close() closes the connection.
45 45
 
46 46
 class BoincDb {
47
-    static $instance;       // a DbConn object, or null
48
-    static $dbnum;          // which replica we're connected to
47
+    static $instance; // a DbConn object, or null
48
+    static $dbnum; // which replica we're connected to
49 49
 
50 50
     // connect to DB $dbnum (0, 1, ...)
51 51
     // If the requested DB doesn't exist or connection fails, connect to DB 0.
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         self::$instance = null;
57 57
         $config = get_config();
58 58
         if ($dbnum) {
59
-            $r = $dbnum==1?'':strval($dbnum);
59
+            $r = $dbnum == 1 ? '' : strval($dbnum);
60 60
             $host = parse_config($config, sprintf('<replica%s_db_host>', $r));
61 61
             $name = parse_config($config, sprintf('<replica%s_db_name>', $r));
62 62
             $user = parse_config($config, sprintf('<replica%s_db_user>', $r));
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
         $db = BoincDb::get();
202 202
         return $db->update($this, 'user', $clause);
203 203
     }
204
-    static function enum($where_clause, $order_clause=null) {
204
+    static function enum($where_clause, $order_clause = null) {
205 205
         $db = BoincDb::get();
206 206
         return $db->enum('user', 'BoincUser', $where_clause, $order_clause);
207 207
     }
208
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
208
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
209 209
         $db = BoincDb::get();
210 210
         return $db->enum_fields(
211 211
             'user', 'BoincUser', $fields, $where_clause, $order_clause
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
         $db = BoincDb::get();
256 256
         return $db->update($this, 'team', $clause);
257 257
     }
258
-    static function enum($where_clause, $order_clause=null) {
258
+    static function enum($where_clause, $order_clause = null) {
259 259
         $db = BoincDb::get();
260 260
         return $db->enum('team', 'BoincTeam', $where_clause, $order_clause);
261 261
     }
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         $db = BoincDb::get();
281 281
         return $db->max('team', $field);
282 282
     }
283
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
283
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
284 284
         $db = BoincDb::get();
285 285
         return $db->enum_fields(
286 286
             'team', 'BoincTeam', $fields, $where_clause, $order_clause
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
         $db = BoincDb::get();
319 319
         return $db->delete($this, 'host');
320 320
     }
321
-    static function enum($where_clause, $order_clause=null) {
321
+    static function enum($where_clause, $order_clause = null) {
322 322
         $db = BoincDb::get();
323 323
         return $db->enum('host', 'BoincHost', $where_clause, $order_clause);
324 324
     }
325
-    static function enum_fields($fields, $where_clause, $order_clause=null) {
325
+    static function enum_fields($fields, $where_clause, $order_clause = null) {
326 326
         $db = BoincDb::get();
327 327
         return $db->enum_fields(
328 328
             'host', 'BoincHost', $fields, $where_clause, $order_clause
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
         $db = BoincDb::get();
445 445
         return $db->update($this, 'app', $clause);
446 446
     }
447
-    static function sum($field, $clause=null) {
447
+    static function sum($field, $clause = null) {
448 448
         $db = BoincDb::get();
449 449
         return $db->sum('app', $field, $clause);
450 450
     }
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
         $db = BoincDb::get();
503 503
         return $db->insert('profile', $clause);
504 504
     }
505
-    static function enum($where_clause=null, $order_clause=null) {
505
+    static function enum($where_clause = null, $order_clause = null) {
506 506
         $db = BoincDb::get();
507 507
         return $db->enum('profile', 'BoincProfile', $where_clause, $order_clause);
508 508
     }
509
-    static function enum_fields($fields, $where_clause=null, $order_clause=null) {
509
+    static function enum_fields($fields, $where_clause = null, $order_clause = null) {
510 510
         $db = BoincDb::get();
511 511
         return $db->enum_fields('profile', 'BoincProfile', $fields, $where_clause, $order_clause);
512 512
     }
@@ -901,12 +901,12 @@  discard block
 block discarded – undo
901 901
         return $db->enum('consent', 'BoincConsent', $where_clause);
902 902
     }
903 903
 
904
-    static function insert ($clause) {
904
+    static function insert($clause) {
905 905
         $db = BoincDb::get();
906 906
         return $db->insert('consent', $clause);
907 907
     }
908 908
 
909
-    static function update ($clause) {
909
+    static function update($clause) {
910 910
         $db = BoincDb::get();
911 911
         return $db->update_aux('consent', $clause);
912 912
     }
@@ -931,17 +931,17 @@  discard block
 block discarded – undo
931 931
         return $db->lookup('consent_type', 'BoincConsentType', $clause);
932 932
     }
933 933
 
934
-    static function enum($where_clause, $order_clause=null) {
934
+    static function enum($where_clause, $order_clause = null) {
935 935
         $db = BoincDb::get();
936 936
         return $db->enum('consent_type', 'BoincConsentType', $where_clause, $order_clause);
937 937
     }
938 938
 
939
-    static function insert ($clause) {
939
+    static function insert($clause) {
940 940
         $db = BoincDb::get();
941 941
         return $db->insert('consent_type', $clause);
942 942
     }
943 943
 
944
-    static function update ($clause) {
944
+    static function update($clause) {
945 945
         $db = BoincDb::get();
946 946
         return $db->update_aux('consent_type', $clause);
947 947
     }
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
         return $db->lookup('latest_consent', 'BoincLatestConsent', $clause);
968 968
     }
969 969
 
970
-    static function enum($where_clause, $order_clause=null) {
970
+    static function enum($where_clause, $order_clause = null) {
971 971
         $db = BoincDb::get();
972 972
         return $db->enum('latest_consent', 'BoincLatestConsent', $where_clause, $order_clause);
973 973
     }
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
 // apply this to any user-supplied strings used in queries
979 979
 //
980 980
 function boinc_real_escape_string($x) {
981
-    if (version_compare(phpversion(),"4.3.0")>=0) {
981
+    if (version_compare(phpversion(), "4.3.0") >= 0) {
982 982
         return BoincDb::escape_string($x);
983 983
     } else {
984 984
         $x = str_replace("'", "\'", $x);
Please login to merge, or discard this patch.