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

DBStaticNews   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 48
rs 10
c 1
b 0
f 0
wmc 6
lcom 0
cbo 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A db_news_update_set() 0 3 1
A db_news_insert_set() 0 5 1
A db_news_delete_by_id() 0 3 1
A db_news_with_survey_select_by_id() 0 7 1
A db_news_list_get_by_query() 0 15 2
1
<?php
2
3
class DBStaticNews {
4
5
  public static function db_news_update_set($announce_time, $text, $detail_url, $announce_id) {
6
    doquery("UPDATE {{announce}} SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}' WHERE `idAnnounce`={$announce_id};");
7
  }
8
9
  public static function db_news_insert_set($announce_time, $text, $detail_url, $user) {
10
    doquery("INSERT INTO {{announce}}
11
        SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}',
12
        `user_id` = {$user['id']}, `user_name` = '" . db_escape($user['username']) . "'");
13
  }
14
15
  public static function db_news_delete_by_id($announce_id) {
16
    doquery("DELETE FROM {{announce}} WHERE `idAnnounce` = {$announce_id} LIMIT 1;");
17
  }
18
19
  public static function db_news_with_survey_select_by_id($announce_id) {
20
    return doquery(
21
      "SELECT a.*, s.survey_id, s.survey_question, s.survey_until
22
        FROM {{announce}} AS a
23
        LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce
24
        WHERE `idAnnounce` = {$announce_id} LIMIT 1;", 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...
25
  }
26
27
  /**
28
   * @param $template
29
   * @param $query_where
30
   * @param $query_limit
31
   *
32
   * @return array|bool|mysqli_result|null
33
   */
34
  public static function db_news_list_get_by_query(&$template, $query_where, $query_limit) {
35
    $announce_list = doquery(
36
      "SELECT a.*, UNIX_TIMESTAMP(`tsTimeStamp`) AS unix_time, u.authlevel, s.*
37
    FROM
38
      {{announce}} AS a
39
      LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce
40
      LEFT JOIN {{users}} AS u ON u.id = a.user_id
41
    {$query_where}
42
    ORDER BY `tsTimeStamp` DESC, idAnnounce" .
43
      ($query_limit ? " LIMIT {$query_limit}" : ''));
44
45
    $template->assign_var('NEWS_COUNT', db_num_rows($announce_list));
46
47
    return $announce_list;
48
  }
49
50
}
51