user_insert::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
/**
4
* @Auther: bhief
5
* @Version: 1.0
6
*
7
* Inserts user information
8
*
9
**/
10
class user_insert {
11
    public $__db;
12
13
	public function __construct($conn){
14
        $this->__db = $conn;
15
	}
16
17
    function check_view_channel($vidid, $user) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
        $stmt = $this->__db->prepare("SELECT * FROM channel_views WHERE viewer = :user AND channel = :vidid");
19
        $stmt->bindParam(":user", $user);
20
        $stmt->bindParam(":vidid", $vidid);
21
        $stmt->execute();
22
        if($stmt->rowCount() === 0) {
23
            $this->add_view_channel($vidid, $user);
24
        }
25
    }
26
    
27
    function add_view_channel($vidid, $user) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
        $stmt = $this->__db->prepare("INSERT INTO channel_views (viewer, channel) VALUES (:user, :vidid)");
29
        $stmt->bindParam(":user", $user);
30
        $stmt->bindParam(":vidid", $vidid);
31
        $stmt->execute();
32
    }   
33
34
    function send_message($author, $subject, $to, $message, $video = "", $type = "nm") {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
        $stmt = $this->__db->prepare("INSERT INTO pms (owner, subject, touser, message, video_attribute, type) VALUES (:owner, :subject, :touser, :message, :video, :type)");
36
        $stmt->bindParam(":owner", $author);
37
        $stmt->bindParam(":subject", $subject);
38
        $stmt->bindParam(":touser", $to);
39
        $stmt->bindParam(":message", $message);
40
        $stmt->bindParam(":video", $video);
41
        $stmt->bindParam(":type", $type);
42
        $stmt->execute();
43
    }   
44
}
45
46
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...