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) { |
|
|
|
|
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) { |
|
|
|
|
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") { |
|
|
|
|
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
|
|
|
?> |
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.