質問編集履歴
3
内容調整
test
CHANGED
File without changes
|
test
CHANGED
@@ -87,3 +87,81 @@
|
|
87
87
|
接続成功!!array(0) { }
|
88
88
|
|
89
89
|
```
|
90
|
+
|
91
|
+
●修正後
|
92
|
+
|
93
|
+
```
|
94
|
+
|
95
|
+
<?php
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
ini_set("display_errors", 1);
|
100
|
+
|
101
|
+
error_reporting(E_ALL);
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
try{
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
$dbh = new PDO('mysql:dbname=hight_school_baseball;host=localhost;charset=utf8mb4'
|
110
|
+
|
111
|
+
,'root'
|
112
|
+
|
113
|
+
,'',
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
[
|
118
|
+
|
119
|
+
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
120
|
+
|
121
|
+
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
122
|
+
|
123
|
+
PDO::ATTR_EMULATE_PREPARES => false,
|
124
|
+
|
125
|
+
]
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
);
|
130
|
+
|
131
|
+
echo '接続成功!!';
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
$stmt = $dbh->prepare("select * from prefectures where id < :id");
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
$stmt->bindValue(':id',10, PDO::PARAM_INT);
|
140
|
+
|
141
|
+
$stmt->execute();
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
$result=[];
|
146
|
+
|
147
|
+
while($data = $stmt->fetch(PDO::FETCH_ASSOC)){
|
148
|
+
|
149
|
+
array_push( $result, $data);
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
var_dump($result);
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
catch(PDOException $e){
|
162
|
+
|
163
|
+
exit($e->getMessage());
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
```
|
2
内容調整
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
内容調整
test
CHANGED
File without changes
|
test
CHANGED
@@ -76,6 +76,8 @@
|
|
76
76
|
|
77
77
|
}
|
78
78
|
|
79
|
+
?>
|
80
|
+
|
79
81
|
```
|
80
82
|
|
81
83
|
●出力結果
|