Completed
Push — work-fleets ( 4aef09...b4179a )
by SuperNova.WS
05:37
created

DBStaticFleetACS::db_acs_insert()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
nc 1
nop 3
dl 0
loc 13
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
class DBStaticFleetACS {
4
5
  /* ACS ****************************************************************************************************************/
6
  /**
7
   * @param $aks_id
8
   *
9
   * @return array
10
   */
11
  public static function db_acs_get_by_group_id($aks_id) {
12
    // TODO - safe
13
    $aks_id = intval($aks_id);
14
    $result = doquery("SELECT * FROM {{aks}} WHERE id = '{$aks_id}' LIMIT 1 FOR UPDATE;", true);
0 ignored issues
show
Documentation introduced by
true is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
15
16
    return is_array($result) && !empty($result) ? $result : array();
17
  }
18
19
  /**
20
   * Purges AKS list
21
   */
22
// USED AS CALLABLE - SEARCH FOR STRING!!!!!!!
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
23
  public static function db_fleet_aks_purge() {
24
    doquery('DELETE FROM `{{aks}}` WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM `{{fleets}}`);');
25
  }
26
27
  /**
28
   * @return array|bool|mysqli_result|null
29
   */
30
  public static function db_acs_get_list() {
31
    $aks_madnessred = doquery('SELECT * FROM {{aks}};');
32
33
    return $aks_madnessred;
34
  }
35
36
  /**
37
   * @param $fleetid
38
   *
39
   * @return array|bool|mysqli_result|null
40
   */
41
  public static function db_acs_get_by_fleet($fleetid) {
42
    $aks = doquery("SELECT * from `{{aks}}` WHERE `flotten` = {$fleetid} LIMIT 1;", '', true);
43
44
    return $aks;
45
  }
46
47
  /**
48
   * @param $fleetid
49
   * @param $user
50
   * @param $objFleet
51
   */
52
  public static function db_acs_insert($fleetid, $user, $objFleet) {
53
    doquery("INSERT INTO {{aks}} SET
54
          `name` = '" . db_escape(classLocale::$lang['flt_acs_prefix'] . $fleetid) . "',
55
          `teilnehmer` = '" . $user['id'] . "',
56
          `flotten` = '" . $fleetid . "',
57
          `ankunft` = '" . $objFleet->time_arrive_to_target . "',
58
          `galaxy` = '" . $objFleet->fleet_end_galaxy . "',
59
          `system` = '" . $objFleet->fleet_end_system . "',
60
          `planet` = '" . $objFleet->fleet_end_planet . "',
61
          `planet_type` = '" . $objFleet->fleet_end_type . "',
62
          `eingeladen` = '" . $user['id'] . "',
63
          `fleet_end_time` = '" . $objFleet->time_return_to_source . "'");
64
  }
65
66
  /**
67
   * @param $userToAddID
68
   * @param $fleetid
69
   *
70
   * @return array|bool|mysqli_result|null
71
   */
72
  public static function db_acs_update($userToAddID, $fleetid) {
73
    return doquery("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};");
74
  }
75
76
77
  /**
78
   * @param $fleet_group_id_list
79
   */
80
  public static function db_acs_delete_by_list($fleet_group_id_list) {
81
    doquery("DELETE FROM {{aks}} WHERE `id` IN ({$fleet_group_id_list})");
82
  }
83
84
85
}
86