msg.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. class msg_m extends Model
  3. {
  4. function __construct()
  5. {
  6. parent::Model();
  7. }
  8. function msg_m()
  9. {
  10. $this->__construct();
  11. }
  12. //取得单独内容信息
  13. function get_c($id,$field)
  14. {
  15. if(!$id || !$field)
  16. {
  17. return false;
  18. }
  19. $sql = "SELECT val FROM ".$this->db->prefix."list_c WHERE id='".$id."' AND `field`='".$field."'";
  20. $rs = $this->db->get_one($sql);
  21. if(!$rs) return false;
  22. return $rs["val"];
  23. }
  24. function get_one($id)
  25. {
  26. $this->db->close_cache();
  27. $sql = " SELECT * ";
  28. $sql.= " FROM ".$this->db->prefix."list ";
  29. $sql.= " WHERE id='".$id."'";
  30. $sql.= " AND status='1' ";
  31. $rs = $this->db->get_one($sql);
  32. if(!$rs)
  33. {
  34. $this->db->open_cache();
  35. return false;
  36. }
  37. if($rs["thumb_id"])
  38. {
  39. $tmp_thumb = sys_format_list($rs["thumb_id"],"img");
  40. $rs["thumb"] = $tmp_thumb[0];
  41. unset($tmp_thumb);
  42. }
  43. $sql = "SELECT field,val FROM ".$this->db->prefix."list_c WHERE id='".$id."'";
  44. $tmp_rs = $this->db->get_all($sql);
  45. if($tmp_rs && is_array($tmp_rs) && count($tmp_rs)>0)
  46. {
  47. foreach($tmp_rs AS $key=>$value)
  48. {
  49. $value["val"] = sys_format_content($value["val"]);
  50. $rs[$value["field"]] = $value["val"];
  51. }
  52. }
  53. $this->db->open_cache();
  54. return $rs;
  55. }
  56. function get_one_fromtype($typeid,$langid="zh")
  57. {
  58. $sql = "SELECT id,langid FROM ".$this->db->prefix."list WHERE identifier='".$typeid."'";
  59. $rslist = $this->db->get_all($sql);
  60. if(!$rslist)
  61. {
  62. return false;
  63. }
  64. $id = 0;
  65. foreach($rslist AS $key=>$value)
  66. {
  67. if($value["langid"] == $langid)
  68. {
  69. $id = $value["id"];
  70. break;
  71. }
  72. }
  73. if(!$id)
  74. {
  75. $id = $rslist[0]["id"];
  76. }
  77. return $this->get_one($id);
  78. }
  79. //更新点击率
  80. function update_hits($id)
  81. {
  82. $sql = "UPDATE ".$this->db->prefix."list SET hits=hits+1 WHERE id='".$id."'";
  83. return $this->db->query($sql);
  84. }
  85. }
  86. ?>