質問編集履歴

1

本文の追記

2016/07/09 10:56

投稿

poooooo
poooooo

スコア125

test CHANGED
File without changes
test CHANGED
@@ -73,3 +73,69 @@
73
73
 
74
74
 
75
75
  どなたかご教授ください。
76
+
77
+
78
+
79
+ ---
80
+
81
+
82
+
83
+ **追記**
84
+
85
+ すみません、そういえばSqlクラスを書いてませんでした。
86
+
87
+
88
+
89
+ ```PHP
90
+
91
+ class Sql {
92
+
93
+ function Sql($sql, $_name="sql", $value) {
94
+
95
+ $this->db = new DbAccess();
96
+
97
+ $stmt = $this->db->dbh->prepare($sql);
98
+
99
+
100
+
101
+ if(!empty($value)) {
102
+
103
+ foreach($value as $key => $val) {
104
+
105
+ if(gettype($val)=="string") {
106
+
107
+ $stmt->bindParam($key+1,$val,PDO::PARAM_STR);
108
+
109
+ } elseif(gettype($val)=="integer") {
110
+
111
+ $stmt->bindParam($key+1,$val,PDO::PARAM_INT);
112
+
113
+ }
114
+
115
+ unset($key,$val);
116
+
117
+ }
118
+
119
+ }
120
+
121
+
122
+
123
+ $this->_result = $stmt->execute();
124
+
125
+ $this->_primary = $this->db->dbh->lastInsertId();
126
+
127
+ $this->$_name = $stmt->fetchAll(PDO::FETCH_ASSOC);
128
+
129
+ return;
130
+
131
+ }
132
+
133
+ }
134
+
135
+ コード
136
+
137
+ ```
138
+
139
+
140
+
141
+ DbAccessクラスはDBに繋いでるだけです。