国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

codeigniter實現get分頁的方法

2024-05-04 23:37:37
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了codeigniter實現get分頁的方法,涉及使用codeigniter框架查詢數據量及針對結果集進行get方法分頁的相關技巧,非常簡單實用,需要的朋友可以參考下

本文實例講述了codeigniter實現get分頁的方法。分享給大家供大家參考。具體實現方法如下:

 

 
  1. public function project_search(){ 
  2. $this->load->library('pagination'); 
  3. $this->load->model('depart_mdl'); 
  4. //獲取搜索需要的信息 
  5. $data = $this->get_project_data(); 
  6. $get_data = $this->input->get(); 
  7. $data = array_merge($data,$get_data); 
  8. //get分頁配置 
  9. $name = $get_data['name']; 
  10. $username = $get_data['username']; 
  11. $budget = $get_data['budget']; 
  12. $type = $get_data['type']; 
  13. $posttime_start = $get_data['posttime_start']; 
  14. $posttime_end = $get_data['posttime_end']; 
  15. $purchase_type = $get_data['purchase_type']; 
  16. $depart_code = $get_data['depart_code']; 
  17. $project_status = $get_data['project_status']; 
  18. $bidder_way = $get_data['bidder_way']; 
  19. $suffix = "?name=$name&username=$username&budget=$budget&type=$type&posttime_start=$posttime_start&posttime_end=$posttime_end&purchase_type=$purchase_type&depart_code=$depart_code&project_status=$project_status&bidder_way=$bidder_way"
  20. $config['base_url'] = site_url('project/project_search').$suffix
  21. $config['total_rows'] = $this->db->count_all($this->db->dbprefix('project')); 
  22. $config['per_page'] = 10; 
  23. $config['page_query_string'] = TRUE; 
  24. //偏移量 
  25. $config['query_string_segment'] = 'page'
  26. $config['uri_segment'] = 3; 
  27. $this->pagination->initialize($config); 
  28. $user = $this->user_mdl->get_user_by_salary_no($this->session->userdata('salary_no')); 
  29. $this->db->from('ustc_project'); 
  30. $this->db->join('ustc_admins','ustc_admins.salary_no=ustc_project.salary_no'); 
  31. if($user->role!=1){ 
  32. $depart_code = explode(',',$user->grant_depart_code); 
  33. $this->db->where_in('grant_depart_code',$depart_code); 
  34. $this->db->or_where('ustc_project.salary_no =',$this->session->userdata('salary_no')); 
  35. if($name != ''){ 
  36. $this->db->like('name',$name); 
  37. if($username != ''){ 
  38. $this->db->like('username',$get_data['username']); 
  39. if($budget != ''){ 
  40. $this->db->like('budget',$get_data['budget']); 
  41. if($type != ''){ 
  42. $this->db->where('type',$get_data['type']); 
  43. if($depart_code != ''){ 
  44. $this->db->where('depart_code',$get_data['depart_code']); 
  45. if($purchase_type != ''){ 
  46. $this->db->where('purchase_type',$get_data['purchase_type']); 
  47. if($project_status != ''){ 
  48. $this->db->where('project_status',$get_data['project_status']); 
  49. if($bidder_way != ''){ 
  50. $this->db->where('bidder_way',$get_data['bidder_way']); 
  51. //時間 
  52. if($posttime_start != ''){ 
  53. $this->db->where('posttime > ',strtotime($get_data['posttime_start'])); 
  54. if($posttime_end != ''){ 
  55. $this->db->where('posttime < ',strtotime($get_data['posttime_end'])); 
  56. if(isset($get_data['page'])){ 
  57. $page_from = $get_data['page']; 
  58. }else
  59. $page_from = 0; 
  60. $this->db->order_by('posttime','desc'); 
  61. $projects = $this->db->limit($config['per_page'],$page_from)->get()->result_array();  
  62. //處理 
  63. for($i=0;$i<count($projects);$i++){ 
  64. $projects[$i]['type'] = $this->manage_info_mdl->get_value_by_id($projects[$i]['type'])->value; 
  65. $projects[$i]['purchase_type'] = $this->manage_info_mdl->get_value_by_id($projects[$i]['purchase_type'])->value; 
  66. $projects[$i]['depart'] = $this->depart_mdl->get_depart_by_code($projects[$i]['depart_code'])->name; 
  67. $data['projects'] = $projects
  68. //獲取當前用戶的角色 
  69. $data['user_role'] = $this->user_mdl->get_user_by_salary_no($this->session->userdata('salary_no'))->role;  
  70. $this->_template('project_search',$data); 

希望本文所述對大家基于codeigniter的php程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 庆安县| 花莲市| 彰化县| 朔州市| 府谷县| 伊吾县| 张家界市| 昭苏县| 舟曲县| 开江县| 连平县| 周口市| 定兴县| 莒南县| 瓮安县| 蕉岭县| 澜沧| 河南省| 溆浦县| 龙陵县| 洪洞县| 龙游县| 德阳市| 莒南县| 察雅县| 临沂市| 榆中县| 沾益县| 都江堰市| 沛县| 锦州市| 新乡市| 黎川县| 太康县| 乌鲁木齐市| 肃宁县| 安岳县| 武乡县| 潮州市| 甘洛县| 长宁区|