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

DBStaticSurveyVote   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
ccs 0
cts 15
cp 0
rs 10
wmc 3
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A db_survey_get_vote() 0 3 1
A db_survey_vote_insert() 0 8 1
A db_survey_vote_get() 0 5 1
1
<?php
2
3
namespace DBStatic;
4
use classSupernova;
5
use mysqli_result;
6
7
class DBStaticSurveyVote {
8
9
  /**
10
   * @param $announce
11
   * @param $user
12
   *
13
   * @return array|bool|mysqli_result|null
14
   */
15
  public static function db_survey_get_vote($announce, $user) {
16
    return classSupernova::$db->doSelectFetch("SELECT `survey_vote_id` FROM `{{survey_votes}}` WHERE survey_parent_id = {$announce['survey_id']} AND survey_vote_user_id = {$user['id']} LIMIT 1;");
17
  }
18
19
20
  /**
21
   * @param $survey_id
22
   * @param $survey_vote_id
23
   * @param $userId
24
   * @param $user_name_unsafe
25
   */
26
  public static function db_survey_vote_insert($survey_id, $survey_vote_id, $userId, $user_name_unsafe) {
27
    classSupernova::$db->doInsertSet(TABLE_SURVEY_VOTES, array(
28
      'survey_parent_id'        => $survey_id,
29
      'survey_parent_answer_id' => $survey_vote_id,
30
      'survey_vote_user_id'     => $userId,
31
      'survey_vote_user_name'   => $user_name_unsafe,
32
    ));
33
  }
34
35
36
  /**
37
   * @param $user
38
   * @param $survey_id
39
   *
40
   * @return array|bool|mysqli_result|null
41
   */
42
  public static function db_survey_vote_get(&$user, $survey_id) {
43
    $is_voted = classSupernova::$db->doSelectFetch("SELECT `survey_vote_id` FROM `{{survey_votes}}` WHERE survey_parent_id = {$survey_id} AND survey_vote_user_id = {$user['id']} FOR UPDATE;");
44
45
    return $is_voted;
46
  }
47
48
}