-
Notifications
You must be signed in to change notification settings - Fork 0
/
messageFunctions.php
41 lines (33 loc) · 1.13 KB
/
messageFunctions.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
<?php
include 'message.php';
//include 'DatabaseConnection.php';
class messageFunctions{
function insertMessage(message $newMessage){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$senderName = $newMessage->senderName;
$email = $newMessage->email;
$subject = $newMessage->subject;
$content = $newMessage->content;
$result = $conn->query("CALL `insertMessage`('$senderName', '$email', '$subject', '$content');");
}
function selectMessage(){
$dbConnection = new DatabaseConnection();
$conn=$dbConnection->connection();
mysqli_set_charset($conn,'utf8');
$sql= $conn->query("CALL `selectMessage`();");
while($rs = $sql->fetch_array(MYSQLI_ASSOC)) {
$newMessage = new message();
$newMessage->id=$rs['id'];
$newMessage->senderName=$rs['senderName'];
$newMessage->email=$rs['email'];
$newMessage->subject=$rs['subject'];
$newMessage->content=$rs['content'];
$messages[]=$newMessage;
}
$conn->close();
return json_encode($messages,JSON_NUMERIC_CHECK | JSON_UNESCAPED_UNICODE);
}
}
?>