-
Notifications
You must be signed in to change notification settings - Fork 3
/
GuestConnect.php
60 lines (40 loc) · 1.21 KB
/
GuestConnect.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
<?php
$dsn = "mysql:host=localhost;dbname=library_v8";
$user = "root";
$pass = "";
$opt = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
$pdo = new PDO($dsn, $user, $pass, $opt);
class Guest {
private $conn;
public function __construct(PDO $pdo) {
try {
$this->conn = $pdo;
} catch (PDOException $e) {
echo $e->getMessage();
die("Connection Error");
}
// public function view($conn) {
$stmt = $pdo->prepare("call LIST()");
try {
$stmt->execute($_GET);
$book = $stmt->setFetchMode(PDO::FETCH_ASSOC);
while ($book = $stmt->fetch()) {
echo '<div class="row justify-content-center align-items-center">';
echo '<pre>'; print_r($book); echo '</pre>';
echo '</div>';
}
} catch (PDOException $e) {
echo $e->getMessage();
$error = $e->errorInfo();
die();
}
}
}
$guest = new Guest($pdo);
//$guest->view($pdo);
//try {
// $pdo = new PDO($dsn, $user, $pass);
// $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// } catch (PDOException $e) {
// die($e->getMessage());
//}