@@ -9,13 +9,13 @@ public function __construct()
99 $ this ->load ->database ();//加载数据库
1010 }
1111
12- public function home ()
12+ public function home ($ config )
1313 {
1414 //$query = $this->db->query('select * from article order by id desc limit 0,8');//加载数据表
1515
1616 //调用article表,按id倒序排列并显示8条数据
17- $ data = $ this ->db ->from ( ' article ' )->order_by ( ' id ' , ' desc ' )-> limit ( 8 )-> get ( );
18- return $ data ->result ();
17+ $ data = $ this ->db ->order_by ( ' id ' , ' desc ' )->get ( ' article ' , $ config [ ' per_page ' ], $ this -> uri -> segment ( 3 ) );
18+ return $ data ->result ();//单结果标准查询(对象形式)
1919 }
2020
2121 public function article ($ id )
@@ -26,14 +26,14 @@ public function article($id)
2626
2727 public function tweets ($ config )
2828 {
29- $ query = $ this ->db ->order_by ('id ' , 'desc ' )->get ('tweets ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
30- return $ query ->result_array ();
29+ $ data = $ this ->db ->order_by ('id ' , 'desc ' )->get ('tweets ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
30+ return $ data ->result_array ();//单结果标准查询(数组形式)
3131 }
3232
3333 public function diaries ($ config )
3434 {
35- $ query = $ this ->db ->get ('diaries ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
36- return $ query ->result_array ();
35+ $ data = $ this ->db ->get ('diaries ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
36+ return $ data ->result_array ();
3737 }
3838
3939 public function diaries_details ($ id )//日记详情
@@ -42,16 +42,22 @@ public function diaries_details($id)//日记详情
4242 return $ data ->result_array ()[0 ];
4343 }
4444
45- public function learn ($ config )
45+ public function category ()
46+ {
47+ $ data = $ this ->db ->group_by ('type ' )->get ('article ' );
48+ return $ data ->result ();
49+ }
50+
51+ public function category_details ($ config , $ type )//分类详情
4652 {
47- $ query = $ this ->db ->get ('article ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
48- return $ query -> result_array ();
53+ $ data = $ this ->db ->where ( ' type= ' , $ type )-> get ('article ' , $ config ['per_page ' ], $ this ->uri ->segment (4 ));
54+ return $ data -> result ();
4955 }
5056
5157 public function guestbook ($ config )
5258 {
53- $ query = $ this ->db ->get ('guestbook ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
54- return $ query ->result_array ();
59+ $ data = $ this ->db ->get ('guestbook ' , $ config ['per_page ' ], $ this ->uri ->segment (3 ));
60+ return $ data ->result_array ();
5561 }
5662
5763 public function message ($ name , $ content , $ date )
0 commit comments