質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,6 +13,52 @@
|
|
13
13
|
### 発生している問題・エラーメッセージ
|
14
14
|
|
15
15
|
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
// 接続チェックOK
|
20
|
+
|
21
|
+
function connect()
|
22
|
+
|
23
|
+
{
|
24
|
+
|
25
|
+
$host = DB_HOST;
|
26
|
+
|
27
|
+
$db = DB_NAME;
|
28
|
+
|
29
|
+
$user = DB_USER;
|
30
|
+
|
31
|
+
$pass = DB_PASS;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
$dsn = "mysql:host=$host;dbname=$db;charset=utf8mb4";
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
try {
|
40
|
+
|
41
|
+
$pdo = new PDO($dsn, $user, $pass, [
|
42
|
+
|
43
|
+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
44
|
+
|
45
|
+
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
|
46
|
+
|
47
|
+
]);
|
48
|
+
|
49
|
+
return $pdo;
|
50
|
+
|
51
|
+
} catch(PDOException $e) {
|
52
|
+
|
53
|
+
echo "接続失敗です!". $e->getMessage();
|
54
|
+
|
55
|
+
exit();
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
```
|
16
62
|
|
17
63
|
```
|
18
64
|
|