質問編集履歴

1

DB接続クラスの追記をしました

2020/05/07 06:08

投稿

hianmain
hianmain

スコア0

test CHANGED
File without changes
test CHANGED
@@ -26,6 +26,8 @@
26
26
 
27
27
  ```ここに言語名を入力
28
28
 
29
+ login.php
30
+
29
31
  <?php
30
32
 
31
33
 
@@ -136,6 +138,46 @@
136
138
 
137
139
  </form>
138
140
 
141
+
142
+
143
+ DBConnect.php
144
+
145
+ <?php
146
+
147
+
148
+
149
+ class DBConnect{
150
+
151
+
152
+
153
+ public function getDBH(){
154
+
155
+ $dsn = 'mysql:host=localhost;dbname=SLJ;charset=utf8mb4';
156
+
157
+ $user = 'root';
158
+
159
+ $pass = 'sljslj';
160
+
161
+
162
+
163
+ try{
164
+
165
+ $dbh = new PDO($dsn, $user, $pass);
166
+
167
+ $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
168
+
169
+ return $dbh;
170
+
171
+ }catch(PDOException $e){
172
+
173
+ die ('エラー:' . $e->getMessage());
174
+
175
+ }
176
+
177
+ }
178
+
179
+ }
180
+
139
181
  ```
140
182
 
141
183