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

DBStaticSurveyAnswer::db_survey_answer_insert()   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 2
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
class DBStaticSurveyAnswer {
4
5
  public static function db_survey_answer_insert($survey_id, $survey_answer) {
6
    doquery("INSERT INTO {{survey_answers}} SET `survey_parent_id` = {$survey_id}, `survey_answer_text` = '{$survey_answer}'");
7
  }
8
9
  public static function db_survey_answer_text_select_by_news($announce) {
10
    return doquery("SELECT survey_answer_text FROM {{survey_answers}} WHERE survey_parent_id = {$announce['survey_id']};");
11
  }
12
13
  /**
14
   * @param $announce
15
   *
16
   * @return array|bool|mysqli_result|null
17
   */
18
  public static function db_survey_answers_get_list_by_parent($announce) {
19
    $survey_query = doquery("SELECT * FROM {{survey_answers}} WHERE survey_parent_id  = {$announce['survey_id']} ORDER BY survey_answer_id;");
20
21
    return $survey_query;
22
  }
23
24
  /**
25
   * @param $announce
26
   *
27
   * @return array|bool|mysqli_result|null
28
   */
29
  public static function db_survey_get_answer_texts($announce) {
30
    $survey_query = doquery(
31
      "SELECT survey_answer_text AS `TEXT`, count(DISTINCT survey_vote_id) AS `VOTES`
32
          FROM `{{survey_answers}}` AS sa
33
            LEFT JOIN `{{survey_votes}}` AS sv ON sv.survey_parent_answer_id = sa.survey_answer_id
34
          WHERE sa.survey_parent_id = {$announce['survey_id']}
35
          GROUP BY survey_answer_id
36
          ORDER BY survey_answer_id;"
37
    );
38
39
    return $survey_query;
40
  }
41
42
  /**
43
   * @param $survey_id
44
   * @param $survey_vote_id
45
   *
46
   * @return array|bool|mysqli_result|null
47
   */
48
  public static function db_survey_answer_get($survey_id, $survey_vote_id) {
49
    $is_answer_exists = doquery("SELECT `survey_answer_id` FROM `{{survey_answers}}` WHERE survey_parent_id = {$survey_id} AND survey_answer_id = {$survey_vote_id};", 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...
50
51
    return $is_answer_exists;
52
  }
53
54
}