質問編集履歴
10
from action 追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
|
114
114
|
|
115
|
-
<form action="" accept-charset="utf-8" method="post">
|
115
|
+
<form action="post" accept-charset="utf-8" method="post">
|
116
116
|
|
117
117
|
<div>
|
118
118
|
|
9
トランザクションの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -204,45 +204,65 @@
|
|
204
204
|
|
205
205
|
|
206
206
|
|
207
|
-
class Tcomment extends \Model
|
207
|
+
class Tcomment extends \Model
|
208
208
|
|
209
209
|
{
|
210
210
|
|
211
|
-
|
212
|
-
|
213
|
-
|
211
|
+
public static function insert_datas($onamae,$comment)
|
214
|
-
|
212
|
+
|
215
|
-
|
213
|
+
{
|
214
|
+
|
216
|
-
|
215
|
+
try{
|
216
|
+
|
217
|
-
|
217
|
+
DB::start_transaction();
|
218
|
-
|
218
|
+
|
219
|
+
|
220
|
+
|
219
|
-
|
221
|
+
$query = DB::insert('t_comment')->set(array(
|
220
|
-
|
222
|
+
|
221
|
-
|
223
|
+
'name'=>$onamae,
|
222
|
-
|
224
|
+
|
223
|
-
|
225
|
+
'comment'=>$comment,
|
224
|
-
|
226
|
+
|
225
|
-
|
227
|
+
))->execute();
|
228
|
+
|
229
|
+
|
230
|
+
|
226
|
-
|
231
|
+
DB::commit_transaction();
|
232
|
+
|
233
|
+
|
234
|
+
|
227
|
-
|
235
|
+
}catch(Exception $e){
|
236
|
+
|
237
|
+
|
238
|
+
|
228
|
-
|
239
|
+
DB::rollback_transaction();
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
229
|
-
|
245
|
+
$query = DB::query('SELECT * FROM t_comment');
|
230
|
-
|
246
|
+
|
247
|
+
|
248
|
+
|
231
|
-
|
249
|
+
return $query->execute();
|
232
|
-
|
250
|
+
|
251
|
+
|
252
|
+
|
233
|
-
|
253
|
+
}
|
234
|
-
|
235
|
-
|
236
|
-
|
254
|
+
|
237
|
-
|
255
|
+
public static function get_datas()
|
238
|
-
|
256
|
+
|
239
|
-
|
257
|
+
{
|
240
|
-
|
258
|
+
|
241
|
-
|
259
|
+
$query = DB::query('SELECT * FROM t_comment');
|
242
|
-
|
260
|
+
|
261
|
+
|
262
|
+
|
243
|
-
|
263
|
+
return $query->execute();
|
244
|
-
|
264
|
+
|
245
|
-
|
265
|
+
}
|
246
266
|
|
247
267
|
|
248
268
|
|
8
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -28,7 +28,9 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
|
31
|
+
if (Input::method() == 'POST')
|
32
|
+
|
33
|
+
{
|
32
34
|
|
33
35
|
|
34
36
|
|
@@ -48,7 +50,7 @@
|
|
48
50
|
|
49
51
|
|
50
52
|
|
51
|
-
}
|
53
|
+
}
|
52
54
|
|
53
55
|
}
|
54
56
|
|
@@ -204,40 +206,48 @@
|
|
204
206
|
|
205
207
|
class Tcomment extends \Model
|
206
208
|
|
207
|
-
|
209
|
+
{
|
208
|
-
|
209
|
-
|
210
|
-
|
210
|
+
|
211
|
+
|
212
|
+
|
211
|
-
|
213
|
+
public static function insert_datas($onamae,$comment)
|
214
|
+
|
212
|
-
|
215
|
+
{
|
216
|
+
|
217
|
+
|
218
|
+
|
213
|
-
|
219
|
+
$query = DB::insert('t_comment')->set(array(
|
214
|
-
|
220
|
+
|
215
|
-
'name'=>$onamae,
|
221
|
+
'name'=>$onamae,
|
216
|
-
|
222
|
+
|
217
|
-
'comment'=>$comment,
|
223
|
+
'comment'=>$comment,
|
218
|
-
|
224
|
+
|
219
|
-
))->execute();
|
225
|
+
))->execute();
|
220
|
-
|
226
|
+
|
227
|
+
|
228
|
+
|
221
|
-
$query = DB::query('SELECT * FROM t_comment');
|
229
|
+
$query = DB::query('SELECT * FROM t_comment');
|
222
|
-
|
230
|
+
|
223
|
-
return $query->execute();
|
231
|
+
return $query->execute();
|
224
|
-
|
232
|
+
|
225
|
-
}
|
233
|
+
}
|
226
|
-
|
234
|
+
|
235
|
+
|
236
|
+
|
227
|
-
public static function get_datas()
|
237
|
+
public static function get_datas()
|
228
|
-
|
238
|
+
|
229
|
-
{
|
239
|
+
{
|
230
|
-
|
240
|
+
|
231
|
-
$query = DB::query('SELECT * FROM t_comment');
|
241
|
+
$query = DB::query('SELECT * FROM t_comment');
|
232
|
-
|
242
|
+
|
233
|
-
return $query->execute();
|
243
|
+
return $query->execute();
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
|
234
248
|
|
235
249
|
}
|
236
250
|
|
237
|
-
|
238
|
-
|
239
|
-
}
|
240
|
-
|
241
251
|
?>
|
242
252
|
|
243
253
|
```
|
7
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -184,7 +184,7 @@
|
|
184
184
|
|
185
185
|
|
186
186
|
|
187
|
-
```
|
187
|
+
```php
|
188
188
|
|
189
189
|
//Model
|
190
190
|
|
@@ -202,128 +202,42 @@
|
|
202
202
|
|
203
203
|
|
204
204
|
|
205
|
-
class Tcomment extends \Model
|
205
|
+
class Tcomment extends \Model
|
206
|
+
|
207
|
+
{
|
206
208
|
|
207
209
|
|
208
210
|
|
209
211
|
public static function insert_datas($onamae,$comment)
|
210
212
|
|
213
|
+
{ $query = DB::insert('t_comment')->set(array(
|
214
|
+
|
215
|
+
'name'=>$onamae,
|
216
|
+
|
217
|
+
'comment'=>$comment,
|
218
|
+
|
219
|
+
))->execute();
|
220
|
+
|
221
|
+
$query = DB::query('SELECT * FROM t_comment');
|
222
|
+
|
223
|
+
return $query->execute();
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
public static function get_datas()
|
228
|
+
|
211
|
-
{
|
229
|
+
{
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
230
|
+
|
216
|
-
|
217
|
-
$query->columns(array(
|
218
|
-
|
219
|
-
'name',
|
220
|
-
|
221
|
-
'comment',
|
222
|
-
|
223
|
-
));
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
$query->values(array(
|
230
|
-
|
231
|
-
'$onamae',
|
232
|
-
|
233
|
-
'$comment',
|
234
|
-
|
235
|
-
));
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
231
|
+
$query = DB::query('SELECT * FROM t_comment');
|
242
|
-
|
243
|
-
|
244
|
-
|
232
|
+
|
245
|
-
|
233
|
+
return $query->execute();
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
}
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
public static function get_datas()
|
254
|
-
|
255
|
-
{
|
256
|
-
|
257
|
-
$query = DB::query('SELECT * FROM t_comment');
|
258
|
-
|
259
|
-
return $query->execute();
|
260
|
-
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
234
|
|
265
235
|
}
|
266
236
|
|
237
|
+
|
238
|
+
|
267
|
-
|
239
|
+
}
|
240
|
+
|
268
|
-
|
241
|
+
?>
|
269
|
-
|
270
242
|
|
271
243
|
```
|
272
|
-
|
273
|
-
```php
|
274
|
-
|
275
|
-
//Model
|
276
|
-
|
277
|
-
<?php
|
278
|
-
|
279
|
-
/**
|
280
|
-
|
281
|
-
* コメントテーブル(t_comment)
|
282
|
-
|
283
|
-
*/
|
284
|
-
|
285
|
-
namespace Model;
|
286
|
-
|
287
|
-
use DB;
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
class Tcomment extends \Model
|
292
|
-
|
293
|
-
{
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
public static function insert_datas($onamae,$comment)
|
298
|
-
|
299
|
-
{ $query = DB::insert('t_comment')->set(array(
|
300
|
-
|
301
|
-
'name'=>$onamae,
|
302
|
-
|
303
|
-
'comment'=>$comment,
|
304
|
-
|
305
|
-
))->execute();
|
306
|
-
|
307
|
-
$query = DB::query('SELECT * FROM t_comment');
|
308
|
-
|
309
|
-
return $query->execute();
|
310
|
-
|
311
|
-
}
|
312
|
-
|
313
|
-
public static function get_datas()
|
314
|
-
|
315
|
-
{
|
316
|
-
|
317
|
-
$query = DB::query('SELECT * FROM t_comment');
|
318
|
-
|
319
|
-
return $query->execute();
|
320
|
-
|
321
|
-
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
}
|
326
|
-
|
327
|
-
?>
|
328
|
-
|
329
|
-
```
|
6
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -228,7 +228,7 @@
|
|
228
228
|
|
229
229
|
$query->values(array(
|
230
230
|
|
231
|
-
$onamae,
|
231
|
+
'$onamae',
|
232
232
|
|
233
233
|
'$comment',
|
234
234
|
|
5
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -288,60 +288,42 @@
|
|
288
288
|
|
289
289
|
|
290
290
|
|
291
|
-
class Tcomment extends \Model
|
291
|
+
class Tcomment extends \Model
|
292
|
+
|
293
|
+
{
|
292
294
|
|
293
295
|
|
294
296
|
|
295
297
|
public static function insert_datas($onamae,$comment)
|
296
298
|
|
299
|
+
{ $query = DB::insert('t_comment')->set(array(
|
300
|
+
|
301
|
+
'name'=>$onamae,
|
302
|
+
|
303
|
+
'comment'=>$comment,
|
304
|
+
|
305
|
+
))->execute();
|
306
|
+
|
307
|
+
$query = DB::query('SELECT * FROM t_comment');
|
308
|
+
|
309
|
+
return $query->execute();
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
public static function get_datas()
|
314
|
+
|
297
|
-
{
|
315
|
+
{
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
316
|
+
|
302
|
-
|
303
|
-
'name'=>$onamae,
|
304
|
-
|
305
|
-
'comment'=>$comment,
|
306
|
-
|
307
|
-
))->execute();
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
317
|
+
$query = DB::query('SELECT * FROM t_comment');
|
316
|
-
|
317
|
-
|
318
|
-
|
318
|
+
|
319
|
-
|
319
|
+
return $query->execute();
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
public static function get_datas()
|
328
|
-
|
329
|
-
{
|
330
|
-
|
331
|
-
$query = DB::query('SELECT * FROM t_comment');
|
332
|
-
|
333
|
-
return $query->execute();
|
334
|
-
|
335
|
-
}
|
336
|
-
|
337
|
-
|
338
320
|
|
339
321
|
}
|
340
322
|
|
323
|
+
|
324
|
+
|
325
|
+
}
|
326
|
+
|
341
327
|
?>
|
342
328
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
329
|
```
|
4
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -228,7 +228,7 @@
|
|
228
228
|
|
229
229
|
$query->values(array(
|
230
230
|
|
231
|
-
|
231
|
+
$onamae,
|
232
232
|
|
233
233
|
'$comment',
|
234
234
|
|
@@ -264,8 +264,84 @@
|
|
264
264
|
|
265
265
|
}
|
266
266
|
|
267
|
+
?
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
```php
|
274
|
+
|
275
|
+
//Model
|
276
|
+
|
277
|
+
<?php
|
278
|
+
|
279
|
+
/**
|
280
|
+
|
281
|
+
* コメントテーブル(t_comment)
|
282
|
+
|
283
|
+
*/
|
284
|
+
|
285
|
+
namespace Model;
|
286
|
+
|
287
|
+
use DB;
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
class Tcomment extends \Model {
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
public static function insert_datas($onamae,$comment)
|
296
|
+
|
297
|
+
{
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
$query = DB::insert('t_comment')->set(array(
|
302
|
+
|
303
|
+
'name'=>$onamae,
|
304
|
+
|
305
|
+
'comment'=>$comment,
|
306
|
+
|
307
|
+
))->execute();
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
$query = DB::query('SELECT * FROM t_comment');
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
return $query->execute();
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
public static function get_datas()
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
$query = DB::query('SELECT * FROM t_comment');
|
332
|
+
|
333
|
+
return $query->execute();
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
}
|
340
|
+
|
267
341
|
?>
|
268
342
|
|
269
343
|
|
270
344
|
|
345
|
+
|
346
|
+
|
271
347
|
```
|
3
定義の変更をしました。エラーは出ないのですが、テーブルへの新規登録もなく前と何も変わりません。
test
CHANGED
File without changes
|
test
CHANGED
@@ -42,6 +42,8 @@
|
|
42
42
|
|
43
43
|
$comment_data = Tcomment::insert_datas($onamae, $comment);
|
44
44
|
|
45
|
+
|
46
|
+
|
45
47
|
$this->load->model('tcomment');
|
46
48
|
|
47
49
|
|
@@ -110,8 +112,6 @@
|
|
110
112
|
|
111
113
|
<form action="" accept-charset="utf-8" method="post">
|
112
114
|
|
113
|
-
|
114
|
-
|
115
115
|
<div>
|
116
116
|
|
117
117
|
<label for="form_onamae">お名前</label>
|
@@ -140,6 +140,8 @@
|
|
140
140
|
|
141
141
|
</form>
|
142
142
|
|
143
|
+
|
144
|
+
|
143
145
|
<div>
|
144
146
|
|
145
147
|
<table>
|
@@ -178,8 +180,6 @@
|
|
178
180
|
|
179
181
|
</body>
|
180
182
|
|
181
|
-
|
182
|
-
|
183
183
|
```
|
184
184
|
|
185
185
|
|
@@ -206,7 +206,7 @@
|
|
206
206
|
|
207
207
|
|
208
208
|
|
209
|
-
public static function insert_datas()
|
209
|
+
public static function insert_datas($onamae,$comment)
|
210
210
|
|
211
211
|
{
|
212
212
|
|
@@ -228,29 +228,21 @@
|
|
228
228
|
|
229
229
|
$query->values(array(
|
230
230
|
|
231
|
+
'$onamae',
|
232
|
+
|
231
|
-
'$
|
233
|
+
'$comment',
|
232
234
|
|
233
235
|
));
|
234
236
|
|
235
237
|
|
236
238
|
|
237
|
-
|
239
|
+
|
238
|
-
|
239
|
-
|
240
|
+
|
240
|
-
|
241
|
-
'name' => '$comment',
|
242
|
-
|
243
|
-
);
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
$this->db->insert('t_comment', $data);
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
241
|
+
$query = DB::query('SELECT * FROM t_comment');
|
252
|
-
|
242
|
+
|
243
|
+
|
244
|
+
|
253
|
-
|
245
|
+
return $query->execute();
|
254
246
|
|
255
247
|
|
256
248
|
|
2
コントロールからモデルへのデータの受け渡し文
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,9 @@
|
|
26
26
|
|
27
27
|
{
|
28
28
|
|
29
|
+
|
30
|
+
|
29
|
-
if (Input::method() == 'POST') {
|
31
|
+
if (Input::method() == 'POST') {
|
30
32
|
|
31
33
|
|
32
34
|
|
@@ -38,7 +40,11 @@
|
|
38
40
|
|
39
41
|
|
40
42
|
|
41
|
-
$comment_data = Tcomment::insert_datas();
|
43
|
+
$comment_data = Tcomment::insert_datas($onamae, $comment);
|
44
|
+
|
45
|
+
$this->load->model('tcomment');
|
46
|
+
|
47
|
+
|
42
48
|
|
43
49
|
}
|
44
50
|
|
@@ -86,8 +92,6 @@
|
|
86
92
|
|
87
93
|
//Views
|
88
94
|
|
89
|
-
|
90
|
-
|
91
95
|
<!DOCTYPE html>
|
92
96
|
|
93
97
|
<html lang="ja">
|
@@ -104,7 +108,7 @@
|
|
104
108
|
|
105
109
|
|
106
110
|
|
107
|
-
<form action="
|
111
|
+
<form action="" accept-charset="utf-8" method="post">
|
108
112
|
|
109
113
|
|
110
114
|
|
@@ -112,7 +116,7 @@
|
|
112
116
|
|
113
117
|
<label for="form_onamae">お名前</label>
|
114
118
|
|
115
|
-
<input name="onamae" value="" type="text" id="
|
119
|
+
<input name="onamae" value="" type="text" id="onamae">
|
116
120
|
|
117
121
|
</div>
|
118
122
|
|
@@ -122,13 +126,13 @@
|
|
122
126
|
|
123
127
|
<label for="form_comment">コメント</label>
|
124
128
|
|
125
|
-
<input name="comment" value="" type="text" id="
|
129
|
+
<input name="comment" value="" type="text" id="comment">
|
126
130
|
|
127
131
|
</div>
|
128
132
|
|
129
133
|
|
130
134
|
|
131
|
-
<div
|
135
|
+
<div>
|
132
136
|
|
133
137
|
<input name="submit" value="登録" type="submit" id="form_submit">
|
134
138
|
|
@@ -174,6 +178,8 @@
|
|
174
178
|
|
175
179
|
</body>
|
176
180
|
|
181
|
+
|
182
|
+
|
177
183
|
```
|
178
184
|
|
179
185
|
|
@@ -210,7 +216,7 @@
|
|
210
216
|
|
211
217
|
$query->columns(array(
|
212
218
|
|
213
|
-
'
|
219
|
+
'name',
|
214
220
|
|
215
221
|
'comment',
|
216
222
|
|
@@ -226,6 +232,28 @@
|
|
226
232
|
|
227
233
|
));
|
228
234
|
|
235
|
+
|
236
|
+
|
237
|
+
$data = array(
|
238
|
+
|
239
|
+
'title' => '$onamae',
|
240
|
+
|
241
|
+
'name' => '$comment',
|
242
|
+
|
243
|
+
);
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
$this->db->insert('t_comment', $data);
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
$query = DB::query('SELECT * FROM t_comment');
|
252
|
+
|
253
|
+
return $query->execute();
|
254
|
+
|
255
|
+
|
256
|
+
|
229
257
|
}
|
230
258
|
|
231
259
|
|
1
insert文 受け渡し文の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,220 +6,246 @@
|
|
6
6
|
|
7
7
|
<?php
|
8
8
|
|
9
|
+
/**
|
10
|
+
|
11
|
+
* Board Controller.
|
12
|
+
|
13
|
+
*/
|
14
|
+
|
9
15
|
use \Model\Tcomment;
|
10
16
|
|
11
17
|
|
12
18
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
19
|
class Controller_Board extends Controller
|
18
20
|
|
21
|
+
|
22
|
+
|
19
23
|
{
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
public function action_
|
25
|
+
public function action_post()
|
24
|
-
|
26
|
+
|
25
|
-
{
|
27
|
+
{
|
28
|
+
|
26
|
-
|
29
|
+
if (Input::method() == 'POST') {
|
30
|
+
|
31
|
+
|
32
|
+
|
27
|
-
|
33
|
+
$onamae = Input::post('onamae');
|
34
|
+
|
35
|
+
|
36
|
+
|
28
|
-
|
37
|
+
$comment = Input::post('comment');
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
$comment_data = Tcomment::insert_datas();
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
public function action_index()
|
52
|
+
|
53
|
+
{
|
54
|
+
|
29
|
-
|
55
|
+
$view = View::forge('board/index');
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
$comment_data = Tcomment::get_datas();
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
$view->comment_data = $comment_data;
|
64
|
+
|
65
|
+
return $view;
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
30
72
|
|
31
73
|
}
|
32
74
|
|
75
|
+
|
76
|
+
|
77
|
+
?>
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
```PHP
|
86
|
+
|
87
|
+
//Views
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
<!DOCTYPE html>
|
92
|
+
|
93
|
+
<html lang="ja">
|
94
|
+
|
95
|
+
<head>
|
96
|
+
|
97
|
+
<meta charset="UTF-8">
|
98
|
+
|
99
|
+
<title>入力フォーム表示画面</title>
|
100
|
+
|
101
|
+
</head>
|
102
|
+
|
103
|
+
<body>
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<form action="/post/save" accept-charset="utf-8" method="post">
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
<div>
|
112
|
+
|
113
|
+
<label for="form_onamae">お名前</label>
|
114
|
+
|
115
|
+
<input name="onamae" value="" type="text" id="form_onamae">
|
116
|
+
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<div>
|
122
|
+
|
123
|
+
<label for="form_comment">コメント</label>
|
124
|
+
|
125
|
+
<input name="comment" value="" type="text" id="form_comment">
|
126
|
+
|
127
|
+
</div>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<div class="actions">
|
132
|
+
|
133
|
+
<input name="submit" value="登録" type="submit" id="form_submit">
|
134
|
+
|
135
|
+
<div>
|
136
|
+
|
137
|
+
</form>
|
138
|
+
|
139
|
+
<div>
|
140
|
+
|
141
|
+
<table>
|
142
|
+
|
143
|
+
<tr>
|
144
|
+
|
145
|
+
<th>ID</th>
|
146
|
+
|
147
|
+
<th>名前</th>
|
148
|
+
|
149
|
+
<th>コメント</th>
|
150
|
+
|
151
|
+
<th>登録日</th>
|
152
|
+
|
153
|
+
</tr>
|
154
|
+
|
155
|
+
<?php foreach($comment_data as $data):?>
|
156
|
+
|
157
|
+
<tr>
|
158
|
+
|
159
|
+
<td><?php echo $data['id'];?></td>
|
160
|
+
|
161
|
+
<td><?php echo $data['name'];?></td>
|
162
|
+
|
163
|
+
<td><?php echo $data['comment'];?></td>
|
164
|
+
|
165
|
+
<td><?php echo $data['registed'];?></td>
|
166
|
+
|
167
|
+
</tr>
|
168
|
+
|
169
|
+
<?php endforeach;?>
|
170
|
+
|
171
|
+
</table>
|
172
|
+
|
173
|
+
</div>
|
174
|
+
|
175
|
+
</body>
|
176
|
+
|
177
|
+
```
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
```PHP
|
182
|
+
|
183
|
+
//Model
|
184
|
+
|
185
|
+
<?php
|
186
|
+
|
187
|
+
/**
|
188
|
+
|
189
|
+
* コメントテーブル(t_comment)
|
190
|
+
|
191
|
+
*/
|
192
|
+
|
193
|
+
namespace Model;
|
194
|
+
|
195
|
+
use DB;
|
196
|
+
|
197
|
+
|
198
|
+
|
199
|
+
class Tcomment extends \Model {
|
200
|
+
|
201
|
+
|
202
|
+
|
33
|
-
|
203
|
+
public static function insert_datas()
|
34
|
-
|
204
|
+
|
35
|
-
|
205
|
+
{
|
36
|
-
|
206
|
+
|
207
|
+
|
208
|
+
|
37
|
-
$
|
209
|
+
$query = DB::insert('t_comment');
|
210
|
+
|
38
|
-
|
211
|
+
$query->columns(array(
|
212
|
+
|
213
|
+
'oname',
|
214
|
+
|
215
|
+
'comment',
|
216
|
+
|
217
|
+
));
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
$query->values(array(
|
224
|
+
|
39
|
-
$
|
225
|
+
'$onamae', '$comment',
|
226
|
+
|
40
|
-
|
227
|
+
));
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
public static function get_datas()
|
234
|
+
|
235
|
+
{
|
236
|
+
|
237
|
+
$query = DB::query('SELECT * FROM t_comment');
|
238
|
+
|
41
|
-
|
239
|
+
return $query->execute();
|
42
|
-
|
43
|
-
|
240
|
+
|
44
|
-
|
45
|
-
|
241
|
+
}
|
242
|
+
|
243
|
+
|
46
244
|
|
47
245
|
}
|
48
246
|
|
49
|
-
|
50
|
-
|
51
|
-
public function action_index()
|
52
|
-
|
53
|
-
{ $view = View::forge('Board');
|
54
|
-
|
55
|
-
$form = Fieldset::forge(); $form->add('oname','お名前',array('maxlength'=>8)); $form->add('comment',)
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
$view = View::forge('board/index');
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
$comment_data = Tcomment::get_datas();
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
$view->comment_data = $comment_data;
|
68
|
-
|
69
|
-
return $view;
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
247
|
?>
|
76
248
|
|
249
|
+
|
250
|
+
|
77
251
|
```
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
```PHP
|
84
|
-
|
85
|
-
//Views
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
<!DOCTYPE html>
|
90
|
-
|
91
|
-
<html lang="ja">
|
92
|
-
|
93
|
-
<head>
|
94
|
-
|
95
|
-
<meta charset="UTF-8">
|
96
|
-
|
97
|
-
<title>入力フォーム表示画面</title>
|
98
|
-
|
99
|
-
</head>
|
100
|
-
|
101
|
-
<body>
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
<form action="/post/save" accept-charset="utf-8" method="post">
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
<div>
|
110
|
-
|
111
|
-
<label for="form_onamae">お名前</label>
|
112
|
-
|
113
|
-
<input name="onamae" value="" type="text" id="form_onamae">
|
114
|
-
|
115
|
-
</div>
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<div>
|
120
|
-
|
121
|
-
<label for="form_comment">コメント</label>
|
122
|
-
|
123
|
-
<input name="comment" value="" type="text" id="form_comment">
|
124
|
-
|
125
|
-
</div>
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
<div class="actions">
|
130
|
-
|
131
|
-
<input name="submit" value="登録" type="submit" id="form_submit">
|
132
|
-
|
133
|
-
<div>
|
134
|
-
|
135
|
-
</form>
|
136
|
-
|
137
|
-
<div>
|
138
|
-
|
139
|
-
<table>
|
140
|
-
|
141
|
-
<tr>
|
142
|
-
|
143
|
-
<th>ID</th>
|
144
|
-
|
145
|
-
<th>名前</th>
|
146
|
-
|
147
|
-
<th>コメント</th>
|
148
|
-
|
149
|
-
<th>登録日</th>
|
150
|
-
|
151
|
-
</tr>
|
152
|
-
|
153
|
-
<?php foreach($comment_data as $data):?>
|
154
|
-
|
155
|
-
<tr>
|
156
|
-
|
157
|
-
<td><?php echo $data['id'];?></td>
|
158
|
-
|
159
|
-
<td><?php echo $data['name'];?></td>
|
160
|
-
|
161
|
-
<td><?php echo $data['comment'];?></td>
|
162
|
-
|
163
|
-
<td><?php echo $data['registed'];?></td>
|
164
|
-
|
165
|
-
</tr>
|
166
|
-
|
167
|
-
<?php endforeach;?>
|
168
|
-
|
169
|
-
</table>
|
170
|
-
|
171
|
-
</div>
|
172
|
-
|
173
|
-
</body>
|
174
|
-
|
175
|
-
```
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
```PHP
|
180
|
-
|
181
|
-
//Model
|
182
|
-
|
183
|
-
<?php
|
184
|
-
|
185
|
-
namespace Model;
|
186
|
-
|
187
|
-
use DB;
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
class Model_Tcomment extends \Model_Crud
|
192
|
-
|
193
|
-
{
|
194
|
-
|
195
|
-
protected static $_table_name = 't_comment';
|
196
|
-
|
197
|
-
protected static $_primary_key = 'id';
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
}
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
class Tcomment extends \Model {
|
210
|
-
|
211
|
-
public static function get_datas()
|
212
|
-
|
213
|
-
{
|
214
|
-
|
215
|
-
$query = DB::query('SELECT * FROM t_comment');
|
216
|
-
|
217
|
-
return $query->execute();
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
```
|