module.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. class module_m extends Model
  3. {
  4. function __construct()
  5. {
  6. parent::Model();
  7. }
  8. function module_m()
  9. {
  10. $this->__construct();
  11. }
  12. //取得一个模块的内容信息
  13. function get_one($id)
  14. {
  15. if(!$id)
  16. {
  17. return false;
  18. }
  19. $sql = "SELECT * FROM ".$this->db->prefix."module WHERE id='".$id."'";
  20. return $this->db->get_one($sql);
  21. }
  22. function get_one_from_code($code)
  23. {
  24. if(!$code)
  25. {
  26. return false;
  27. }
  28. $sql = "SELECT * FROM ".$this->db->prefix."module WHERE identifier='".$code."'";
  29. return $this->db->get_one($sql);
  30. }
  31. function get_mid_from_code($code)
  32. {
  33. $sql = "SELECT id FROM ".$this->db->prefix."module WHERE identifier='".$code."'";
  34. $rs = $this->db->get_one($sql);
  35. if(!$rs)
  36. {
  37. return false;
  38. }
  39. return $rs["id"];
  40. }
  41. //取得所有模块中的标识串及ID,并配上对应关系
  42. function get_id_code_list()
  43. {
  44. $sql = "SELECT id,identifier FROM ".$this->db->prefix."module";
  45. $rslist = $this->db->get_all($sql);
  46. if(!$rslist)
  47. {
  48. return false;
  49. }
  50. $idlist = $codelist = array();
  51. foreach($rslist AS $key=>$value)
  52. {
  53. $idlist[$value["id"]] = $value["identifier"];
  54. $codelist[$value["identifier"]] = $value["id"];
  55. }
  56. return array("code"=>$codelist,"id"=>$idlist);
  57. }
  58. function fields_one($id)
  59. {
  60. if(!$id)
  61. {
  62. return false;
  63. }
  64. $sql = "SELECT * FROM ".$this->db->prefix."module_fields WHERE id='".$id."'";
  65. $rs = $this->db->get_one($sql);
  66. return $rs;
  67. }
  68. //取得模块的第一个
  69. function get_module_sub_one($id)
  70. {
  71. $sql = "SELECT * FROM ".$this->db->prefix."list WHERE module_id='".$id."' ORDER BY taxis DESC,post_date DESC,id DESC LIMIT 1";
  72. return $this->db->get_one($sql);
  73. }
  74. function get_module_cateid($id)
  75. {
  76. $sql = "SELECT * FROM ".$this->db->prefix."cate WHERE module_id='".$id."' AND status='1' AND parentid='0' ORDER BY taxis ASC,id DESC LIMIT 1";
  77. return $this->db->get_one($sql);
  78. }
  79. //取得所有支持搜索的模块
  80. function get_all_module()
  81. {
  82. $sql = "SELECT * FROM ".$this->db->prefix."module WHERE ctrl_init='list' AND insearch='1' AND status='1' ORDER BY taxis ASC,id DESC";
  83. return $this->db->get_all($sql);
  84. }
  85. //读取字段列表,这里不使用分表
  86. function fields_index($module_id,$ifstatus=0)
  87. {
  88. if(!$module_id)
  89. {
  90. return false;
  91. }
  92. $sql = "SELECT * FROM ".$this->db->prefix."module_fields WHERE module_id='".$module_id."' ";
  93. if($ifstatus)
  94. {
  95. $sql .= " AND status='1' ";
  96. }
  97. $sql.= " ORDER BY taxis ASC,id DESC ";
  98. return $this->db->get_all($sql);
  99. }
  100. }
  101. ?>