1
+ <?php if (!defined ('BASEPATH ' )) exit ('No direct script access allowed ' );
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: hp
6
+ * Date: 14-3-1
7
+ * Time: 下午4:35
8
+ */
9
+ class Blog extends CI_Controller
10
+ {
11
+
12
+ public function __construct ()
13
+ {
14
+ parent ::__construct ();
15
+
16
+ $ this ->load ->database ();
17
+ $ this ->load ->model ('Blogmodel ' , 'blog ' );
18
+ }
19
+
20
+ public function index ()
21
+ {
22
+ $ data ['query ' ] = $ this ->blog ->get_last_ten_entries ();
23
+ $ this ->load ->view ("bloglist " , $ data );
24
+ }
25
+
26
+
27
+ public function detail ()
28
+ {
29
+ // echo $this->uri->segment(3);
30
+ $ data ["blog " ] = $ this ->blog ->get_by_id ($ this ->uri ->segment (3 ));
31
+ $ this ->load ->view ("blogdetail " , $ data );
32
+ }
33
+
34
+
35
+ public function addBlogPage ()
36
+ {
37
+ $ this ->load ->view ("blogAdd " );
38
+ }
39
+
40
+ public function addBlog ()
41
+ {
42
+ $ this ->blog ->insert_entry ();
43
+ redirect (base_url ("blog " ), 'location ' );
44
+ }
45
+
46
+ public function updatePage ()
47
+ {
48
+ $ id = $ this ->uri ->segment (3 );
49
+ $ data ["blog " ] = $ this ->blog ->get_by_id ($ this ->uri ->segment (3 ));
50
+ $ this ->load ->view ("blogupdate " , $ data );
51
+
52
+ }
53
+
54
+ public function update ()
55
+ {
56
+ $ this ->blog ->update_entry ();
57
+ redirect (base_url ("blog " , "location " ));
58
+ }
59
+
60
+ public function del ()
61
+ {
62
+ $ id = $ this ->uri ->segment (3 );
63
+ $ this ->blog ->delete_by_id ($ id );
64
+ redirect (base_url ("blog " ), "location " );
65
+ }
66
+
67
+ }
0 commit comments