-
Notifications
You must be signed in to change notification settings - Fork 1
/
lib_speaking.php
108 lines (95 loc) · 3.4 KB
/
lib_speaking.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
//CREATE TABLE `alirezaz_Robots`.`LinkRemoverHistory` ( `id` INT NOT NULL AUTO_INCREMENT , `Guid_U` VARCHAR(50) NOT NULL , `All` VARCHAR(2000) NOT NULL , `Today` VARCHAR(2000) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;.0
// define('SERVER_NAME','localhost:3306');
// define("USER_NAME","alirezaz");
// define("USER_PASSWORD","Ab_4317247");
// define("DB_NM","alirezaz_Robots");
class lib_QU{
private $SERVER_NAME;
private $USER_NAME;
private $USER_PASSWORD;
private $DB_NM;
public function __Construct($SERVER_NAME,$USER_NAME,$USER_PASSWORD,$DB_NM){
$this->SERVER_NAME = $SERVER_NAME;
$this->USER_NAME = $USER_NAME;
$this->USER_PASSWORD = $USER_PASSWORD;
$this->DB_NM = $DB_NM;
}
private function cov(){
$SERVER_NAME = $this->SERVER_NAME;
$USER_NAME = $this->USER_NAME;
$USER_PASSWORD = $this->USER_PASSWORD;
$DB_NM = $this->DB_NM;
$all = array(
'S'=>$SERVER_NAME,
'UN'=>$USER_NAME,
'UP'=>$USER_PASSWORD,
'D'=>$DB_NM
);
return $all;
}
private function connect(){
$all = $this->cov();
$link = mysqli_connect($all['S'],$all['UN'],$all['UP'],$all['D']);
if (mysqli_connect_errno($link)){
echo "Failed to connect to MySQL: " . mysqli_connect_error($link);
}
return $link;
}
private function query($qr){
$link = $this->connect();
$result = mysqli_query($link,$qr);
mysqli_close($link);
return $result;
}
// INSERT INTO `LinkRemoverHistory` (`id`, `Guid_U`, `All`, `Today`) VALUES (NULL, 'Guid_U', 'All', 'Today')
public function insert($pats){
$QU = $pats['QU'];
$LEVEL = $pats['LEVEL'];
$GUID_U = $pats['GUID_U'];
$QU = utf8_encode($QU);
$qr = "INSERT INTO `".QUSPEAK."` (`id`, `QU` , `LEVEL`, `GUID_U`) VALUES (NULL, '$QU', '$LEVEL', '$GUID_U');";
$result = $this->query($qr);
return $result;
}
public function select($LEVEL,$GUID_U){
$qr = "SELECT `QU` FROM `".QUSPEAK."` WHERE `LEVEL` = '$LEVEL' AND `GUID_U` = '$GUID_U'";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
foreach($rows as $row){
$QU = utf8_decode($row);
$array[] = $QU;
}
}
return $array;
}
public function select_Def($LEVEL){
$qr = "SELECT `QU` FROM `".QUSPEAK."` WHERE `LEVEL` = '$LEVEL' AND `GUID_U` = 'ALL'";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
foreach($rows as $row){
$QU = utf8_decode($row);
$array[] = $QU;
}
}
return $array;
}
public function updateGUID_U($GUID_new,$GUID_old){
$qr = "UPDATE `".QUSPEAK."` SET `GUID_U` = '$GUID_new' WHERE `GUID_U`='$GUID_old'";
$result = $this->query($qr);
return $result;
}
public function delete($QU,$GUID_U){
$QU = utf8_encode($QU);
$qr = "DELETE FROM `".QUSPEAK."` WHERE `GUID_U` = '$GUID_U' AND `QU` = '$QU'";
$result = $this->query($qr);
return $result;
}
public function count(){
$qr = "select * from ".LINKST;
$result = $this->query($qr);
return mysqli_num_rows($result);
}
}