Completed
Push — work-fleets ( 99e92e...73ed38 )
by SuperNova.WS
07:59
created
includes/classes/DbQueryConstructor.php 2 patches
Doc Comments   +8 added lines, -1 removed lines patch added patch discarded remove patch
@@ -155,10 +155,17 @@  discard block
 block discarded – undo
155 155
     return $this->field(DbSqlLiteral::build($this->db)->literal($field));
156 156
   }
157 157
 
158
+  /**
159
+   * @param string $functionName
160
+   * @param string $alias
161
+   */
158 162
   public function fieldSingleFunction($functionName, $field = '*', $alias = DbSqlLiteral::SQL_LITERAL_ALIAS_NONE) {
159 163
     return $this->field(DbSqlLiteral::build($this->db)->buildSingleArgument($functionName, $field, $alias));
160 164
   }
161 165
 
166
+  /**
167
+   * @param string $alias
168
+   */
162 169
   public function fieldCount($field = '*', $alias = DbSqlLiteral::SQL_LITERAL_ALIAS_NONE) {
163 170
     return $this->field(DbSqlLiteral::build($this->db)->count($field, $alias));
164 171
   }
@@ -240,7 +247,7 @@  discard block
 block discarded – undo
240 247
 
241 248
   /**
242 249
    * @param db_mysql|null $db
243
-   * @param string|object|DBStaticRecord|DbSqlAware $className
250
+   * @param string $className
244 251
    *
245 252
    * @return static
246 253
    */
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
   // TODO - rewrite
229 229
   public function getParamsFromStaticClass($className) {
230 230
     if (is_string($className) && $className && class_exists($className)) {
231
-      if(method_exists($className, 'getDb')) {
231
+      if (method_exists($className, 'getDb')) {
232 232
         $this->setDb($className::getDb());
233 233
       }
234 234
       $this->from($className::$_table);
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
   }
318 318
 
319 319
   protected function compileFrom() {
320
-    $this->_compiledQuery[] = 'FROM `{{' . $this->escapeString($this->table) . '}}`';
320
+    $this->_compiledQuery[] = 'FROM `{{'.$this->escapeString($this->table).'}}`';
321 321
     if (!empty($this->alias)) {
322
-      $this->_compiledQuery[] = 'AS `' . $this->escapeString($this->alias) . '`';
322
+      $this->_compiledQuery[] = 'AS `'.$this->escapeString($this->alias).'`';
323 323
     }
324 324
   }
325 325
 
@@ -329,29 +329,29 @@  discard block
 block discarded – undo
329 329
 
330 330
   protected function compileWhere() {
331 331
     // TODO - fields should be escaped !!
332
-    !empty($this->where) ? $this->_compiledQuery[] = 'WHERE ' . implode(' AND ', $this->where) : false;
332
+    !empty($this->where) ? $this->_compiledQuery[] = 'WHERE '.implode(' AND ', $this->where) : false;
333 333
   }
334 334
 
335 335
   protected function compileGroupBy() {
336 336
     // TODO - fields should be escaped !!
337 337
 //    !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . implode(',', $this->arrayEscape($this->groupBy)) : false;
338
-    !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . $this->selectFieldsToString($this->groupBy) : false;
338
+    !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY '.$this->selectFieldsToString($this->groupBy) : false;
339 339
   }
340 340
 
341 341
   protected function compileOrderBy() {
342 342
     // TODO - fields should be escaped !!
343
-    !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY ' . implode(',', $this->arrayEscape($this->orderBy)) : false;
343
+    !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY '.implode(',', $this->arrayEscape($this->orderBy)) : false;
344 344
   }
345 345
 
346 346
   protected function compileHaving() {
347 347
     // TODO - fields should be escaped !!
348
-    !empty($this->having) ? $this->_compiledQuery[] = 'HAVING ' . implode(' AND ', $this->having) : false;
348
+    !empty($this->having) ? $this->_compiledQuery[] = 'HAVING '.implode(' AND ', $this->having) : false;
349 349
   }
350 350
 
351 351
   protected function compileLimit() {
352 352
     // TODO - fields should be escaped !!
353 353
     if ($limit = $this->fetchOne ? 1 : $this->limit) {
354
-      $this->_compiledQuery[] = 'LIMIT ' . $limit . (!empty($this->offset) ? ' OFFSET ' . $this->offset : '');
354
+      $this->_compiledQuery[] = 'LIMIT '.$limit.(!empty($this->offset) ? ' OFFSET '.$this->offset : '');
355 355
     }
356 356
   }
357 357
 
@@ -395,14 +395,14 @@  discard block
 block discarded – undo
395 395
    */
396 396
   protected function processField($fieldName) {
397 397
     if (is_bool($fieldName)) {
398
-      $result = (string)intval($fieldName);
398
+      $result = (string) intval($fieldName);
399 399
     } elseif (is_numeric($fieldName)) {
400 400
       $result = $fieldName;
401 401
     } elseif (is_null($fieldName)) {
402 402
       $result = 'NULL';
403 403
     } else {
404 404
       // Field has other type - string or should be convertible to string
405
-      $result = (string)$fieldName;
405
+      $result = (string) $fieldName;
406 406
       if (!$fieldName instanceof DbSqlLiteral) {
407 407
         $result = $this->quoteField($fieldName);
408 408
       }
Please login to merge, or discard this patch.
includes/classes/DBStaticUser.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
         ->where('`user_as_ally` IS NULL')
24 24
         ->orderBy(array('`id` DESC'));
25 25
 
26
-    return (string)$query->selectValue();
26
+    return (string) $query->selectValue();
27 27
   }
28 28
 
29 29
   /**
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
       static::buildDBQ()
49 49
         ->field('id')
50 50
         ->where("`user_as_ally` IS NULL")
51
-        ->where("`user_bot` = " . USER_BOT_PLAYER)
51
+        ->where("`user_bot` = ".USER_BOT_PLAYER)
52 52
         ->setForUpdate();
53 53
 
54 54
     return $query->selectIterator();
55 55
   }
56 56
 
57 57
   public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) {
58
-    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) .
59
-      (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '')
58
+    $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']).
59
+      (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '')
60 60
       . " FOR UPDATE";
61 61
 
62 62
     static::getDb()->doquery($query);
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
    */
70 70
   public static function db_user_count($online = false) {
71 71
     return intval(static::getDb()->doQueryFetchValue(
72
-      'SELECT COUNT(`id`) AS `user_count` FROM `{{users}}` WHERE `user_as_ally` IS NULL' . ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
72
+      'SELECT COUNT(`id`) AS `user_count` FROM `{{users}}` WHERE `user_as_ally` IS NULL'.($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '')
73 73
     ));
74 74
   }
75 75
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       ->fieldCount('r.id', 'referral_count')
92 92
       ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm')
93 93
       ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id')
94
-      ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
94
+      ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL')
95 95
       ->groupBy('u.id')
96 96
       ->orderBy("user_as_ally, {$sort} ASC");
97 97
 
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
       ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)')
110 110
       ->where('`user_as_ally` IS NULL')
111 111
       ->having('`days_after_birthday` >= 0')
112
-      ->having('`days_after_birthday` < ' . intval($config_user_birthday_range))
112
+      ->having('`days_after_birthday` < '.intval($config_user_birthday_range))
113 113
       ->setForUpdate();
114 114
 
115 115
     $result = $query->selectIterator();
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
   }
192 192
 
193 193
   public static function db_user_list_set_mass_mail(&$owners_list, $set) {
194
-    return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '', $set);
194
+    return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '', $set);
195 195
   }
196 196
 
197 197
   public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) {
Please login to merge, or discard this patch.
includes/classes/DBStaticRecord.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     $stmt =
85 85
       static::buildDBQ()
86 86
         ->fields($fieldList)
87
-        ->where(static::$_idField . '=' . $recordId);
87
+        ->where(static::$_idField.'='.$recordId);
88 88
 
89 89
     if ($forUpdate) {
90 90
       $stmt->setForUpdate();
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
       $query =
106 106
         static::buildDBQ()
107 107
           ->fields(static::$_idField)
108
-          ->where(array("`" . static::$_idField . "` IN (" . implode(',', $idList) . ")"))
108
+          ->where(array("`".static::$_idField."` IN (".implode(',', $idList).")"))
109 109
           ->selectIterator();
110 110
     } else {
111 111
       $query = new DbEmptyIterator();
Please login to merge, or discard this patch.