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

DBStaticNews::db_news_update_set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 4
dl 0
loc 3
rs 10
c 1
b 0
f 0
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