Completed
Push — work-fleets ( d7065d...1ee481 )
by SuperNova.WS
08:22
created

DBStaticFleetACS   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 96
ccs 0
cts 48
cp 0
rs 10
wmc 9
lcom 0
cbo 3

7 Methods

Rating   Name   Duplication   Size   Complexity  
A db_acs_get_by_group_id() 0 7 3
A db_fleet_aks_purge() 0 9 1
A db_acs_get_list() 0 5 1
A db_acs_get_by_fleet() 0 5 1
A db_acs_insert() 0 14 1
A db_acs_update() 0 3 1
A db_acs_delete_by_list() 0 9 1
1
<?php
2
3
namespace DBStatic;
4
use classLocale;
5
use classSupernova;
6
use mysqli_result;
7
8
class DBStaticFleetACS {
9
10
  /* ACS ****************************************************************************************************************/
11
  /**
12
   * @param $aks_id
13
   *
14
   * @return array
15
   */
16
  public static function db_acs_get_by_group_id($aks_id) {
17
    // TODO - safe
18
    $aks_id = intval($aks_id);
19
    $result = classSupernova::$db->doSelectFetch("SELECT * FROM {{aks}} WHERE id = '{$aks_id}' LIMIT 1 FOR UPDATE;");
20
21
    return is_array($result) && !empty($result) ? $result : array();
22
  }
23
24
  /**
25
   * Purges AKS list
26
   */
27
// 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...
28
  public static function db_fleet_aks_purge() {
29
    classSupernova::$db->doDeleteSql(
30
      'DELETE FROM `{{aks}}` 
31
      WHERE 
32
        `id` NOT IN (
33
          SELECT DISTINCT `fleet_group` FROM `{{fleets}}`
34
        );'
35
    );
36
  }
37
38
  /**
39
   * @return array|bool|mysqli_result|null
40
   */
41
  public static function db_acs_get_list() {
42
    $aks_madnessred = classSupernova::$db->doSelect('SELECT * FROM `{{aks}}`;');
43
44
    return $aks_madnessred;
45
  }
46
47
  /**
48
   * @param $fleetid
49
   *
50
   * @return array|bool|mysqli_result|null
51
   */
52
  public static function db_acs_get_by_fleet($fleetid) {
53
    $aks = classSupernova::$db->doSelectFetch("SELECT * from `{{aks}}` WHERE `flotten` = {$fleetid} LIMIT 1;");
54
55
    return $aks;
56
  }
57
58
  /**
59
   * @param $fleetid
60
   * @param $userId
61
   * @param $objFleet
62
   */
63
  public static function db_acs_insert($fleetid, $userId, $objFleet) {
64
    classSupernova::$db->doInsertSet(TABLE_AKS, array(
65
      'name'           => classLocale::$lang['flt_acs_prefix'] . $fleetid,
66
      'teilnehmer'     => $userId,
67
      'flotten'        => $fleetid,
68
      'ankunft'        => $objFleet->time_arrive_to_target,
69
      'galaxy'         => $objFleet->fleet_end_galaxy,
70
      'system'         => $objFleet->fleet_end_system,
71
      'planet'         => $objFleet->fleet_end_planet,
72
      'planet_type'    => $objFleet->fleet_end_type,
73
      'eingeladen'     => $userId,
74
      'fleet_end_time' => $objFleet->time_return_to_source,
75
    ));
76
  }
77
78
  /**
79
   * @param $userToAddID
80
   * @param $fleetid
81
   *
82
   * @return array|bool|mysqli_result|null
83
   */
84
  public static function db_acs_update($userToAddID, $fleetid) {
85
    return classSupernova::$db->doUpdateReallyComplex("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};");
86
  }
87
88
89
  /**
90
   * @param $fleet_group_id_list
91
   */
92
  public static function db_acs_delete_by_list($fleet_group_id_list) {
93
    classSupernova::$db->doDeleteDanger(
0 ignored issues
show
Deprecated Code introduced by
The method db_mysql::doDeleteDanger() has been deprecated.

This method has been deprecated.

Loading history...
94
      TABLE_AKS,
95
      array(),
96
      array(
97
        "`id` IN ({$fleet_group_id_list})"
98
      )
99
    );
100
  }
101
102
103
}
104