質問編集履歴
4
コード間違いの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
//ご回答をいただく中で以下をさらに試してみましたので追記します
|
82
82
|
|
83
|
-
$statement = $dbh->prepare('UPDATE
|
83
|
+
$statement = $dbh->prepare('UPDATE ex_table SET sports = :sports + 1, food = :food + 1, WHERE date = :str_date');
|
84
84
|
|
85
85
|
|
86
86
|
|
3
コード間違いの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,7 +80,7 @@
|
|
80
80
|
|
81
81
|
//ご回答をいただく中で以下をさらに試してみましたので追記します
|
82
82
|
|
83
|
-
$statement = $dbh->prepare('UPDATE count_table SET sports = :sports + 1, food = :food + 1,
|
83
|
+
$statement = $dbh->prepare('UPDATE count_table SET sports = :sports + 1, food = :food + 1, WHERE date = :str_date');
|
84
84
|
|
85
85
|
|
86
86
|
|
2
試したコードを追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
//カラム名を指定する変数
|
24
24
|
|
25
|
-
$sports = tennis;
|
25
|
+
$sports = 'tennis';
|
26
26
|
|
27
|
-
$food = rice;
|
27
|
+
$food = 'rice';
|
28
28
|
|
29
29
|
|
30
30
|
|
@@ -74,6 +74,30 @@
|
|
74
74
|
|
75
75
|
$dbh = null;
|
76
76
|
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
//ご回答をいただく中で以下をさらに試してみましたので追記します
|
82
|
+
|
83
|
+
$statement = $dbh->prepare('UPDATE count_table SET sports = :sports + 1, food = :food + 1, total_day = total_day + 1 WHERE date = :str_date');
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
$statement->bindColumn('sports', $sports);
|
88
|
+
|
89
|
+
$statement->bindColumn('food', $food);
|
90
|
+
|
91
|
+
$statement->bindParam(':sports', $sports, PDO::PARAM_INT);
|
92
|
+
|
93
|
+
$statement->bindParam(':food', $food, PDO::PARAM_INT);
|
94
|
+
|
95
|
+
$statement->bindParam(':str_today', $str_date, PDO::PARAM_STR);
|
96
|
+
|
97
|
+
$statement->execute();
|
98
|
+
|
99
|
+
$dbh = null;
|
100
|
+
|
77
101
|
```
|
78
102
|
|
79
103
|
|
1
コード間違いの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
//以下が問題の箇所
|
36
36
|
|
37
|
-
$statement = $dbh->prepare('UPDATE ex_table SET :sports = :sports + 1, :food = :food + 1,
|
37
|
+
$statement = $dbh->prepare('UPDATE ex_table SET :sports = :sports + 1, :food = :food + 1, WHERE date = :str_date');
|
38
38
|
|
39
39
|
|
40
40
|
|