回答編集履歴
1
修正
answer
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
<?php
|
3
3
|
|
4
4
|
$sql = "INSERT INTO user(user_name) VALUES ";
|
5
|
+
$placeholder = array();
|
5
6
|
foreach ($aryUsers as $i => $value) {
|
7
|
+
$placeholder[sprintf(":user_name%d", $i)] = $value;
|
6
|
-
$
|
8
|
+
$arySql[] = sprintf("(:user_name%d)", $i);
|
7
|
-
$arySql[] = $placeholder;
|
8
9
|
}
|
9
10
|
$sql .= implode(",", $arySql);
|
10
11
|
$sth = $pdo->prepare($sql);
|
11
12
|
|
12
|
-
foreach ($
|
13
|
+
foreach ($placeholder as $pl => $value) {
|
13
|
-
$sth->bindValue($
|
14
|
+
$sth->bindValue($pl, $value, PDO::PARAM_STR);
|
14
15
|
}
|
15
16
|
$sth->execute();
|
16
17
|
```
|