-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass-db.php
68 lines (61 loc) · 1.98 KB
/
class-db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
class DB
{
private $dbHost = "localhost";
private $dbUsername = "potenzag_zoom";
private $dbPassword = "u&K4akRw9Bug";
private $dbName = "potenzag_zoom";
public function __construct()
{
if (!isset($this->db)) {
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if ($conn->connect_error) {
die("Failed to connect with MySQL: " . $conn->connect_error);
} else {
$this->db = $conn;
}
}
}
public function is_table_empty()
{
$result = $this->db->query("SELECT id FROM token");
if ($result->num_rows) {
return false;
}
return true;
}
public function get_access_token()
{
$sql = $this->db->query("SELECT access_token FROM token");
$result = $sql->fetch_assoc();
return json_decode($result['access_token']);
}
public function get_refersh_token()
{
$result = $this->get_access_token();
return $result->refresh_token;
}
public function update_access_token($token)
{
if ($this->is_table_empty()) {
$this->db->query("INSERT INTO token(access_token) VALUES('$token')");
} else {
$this->db->query("UPDATE token SET access_token = '$token' WHERE id = (SELECT id FROM token)");
}
}
public function add_new_meeting($meeting_id, $passcode, $topic, $join_url, $start_url)
{
$sql = $this->db->query("INSERT INTO tblmeetings(meeting_id,passcode,topic,join_url,start_url) VALUES('$meeting_id','$passcode','$topic','$join_url','$start_url')");
}
public function get_meeting()
{
$sql = $this->db->query("SELECT * FROM tblmeetings");
return $sql;
}
public function get_meeting_by_id($id)
{
$sql = $this->db->query("SELECT * FROM tblmeetings where id={$id}");
return $sql;
}
}