MessageDao.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. class MessageDao {
  3. public $id;
  4. public $from;
  5. public $fromuid;
  6. public $touid;
  7. public $new;
  8. public $time;
  9. public $subject;
  10. public $content;
  11. public $status;
  12. public $_table = 'zhask_message';
  13. public $_primarykey = "id";
  14. public $_fields = array ('id', '$from', '$fromuid', '$touid', '$new', 'time', '$subject', 'content', '$status' );
  15. /**
  16. * 获取用户系统记录数
  17. * @param unknown_type $uid
  18. */
  19. function get_message_count_by_touid($uid = 0) {
  20. $sql = "select count(*) as count from " . t_message . " where new =1 and touid = " . $uid;
  21. $query = Doo::db ()->query ( $sql );
  22. $result = $query->fetch ();
  23. return $result;
  24. }
  25. /**
  26. * 获取系统信息的条数
  27. * @param unknown_type $uid
  28. * @param unknown_type $fromid
  29. * @param unknown_type $time
  30. */
  31. function get_message_count($uid = 0, $fromuid = 0, $time = 7) {
  32. $sql = "select count(*) as count from " . t_message . " where " . $fromuid . " time>UNIX_TIMESTAMP( SUBDATE( now( ) , INTERVAL ".$time." DAY )) and touid = " . $uid;
  33. $query = Doo::db ()->query ( $sql );
  34. $result = $query->fetch ();
  35. return $result;
  36. }
  37. /**
  38. * 获取系统信息
  39. * @param unknown_type $uid
  40. * @param unknown_type $limit
  41. */
  42. public function get_message_list($uid = 0, $fromid = 0, $time = 7, $limit = array()) {
  43. $limit = " order by time desc limit " . $limit ['lower'] . ", " . $limit ['size'] . "";
  44. $sql = "select * from " . t_message . " where " . $fromid . " DATE_SUB(CURDATE(), INTERVAL " . $time . " DAY) <= time and touid = " . $uid ." ".$limit;
  45. $query = Doo::db ()->query ( $sql );
  46. $result = $query->fetchAll ();
  47. return $result;
  48. }
  49. /**
  50. * 发送系统信息
  51. * @param unknown_type $from
  52. * @param unknown_type $fromuid
  53. * @param unknown_type $touid
  54. * @param unknown_type $subject
  55. * @param unknown_type $content
  56. */
  57. public function send_message($from = "", $fromuid = 0, $touid = 0, $subject = "", $content = "",$type=1) {
  58. $time = get_date ();
  59. //发送系统信息
  60. $sql = "INSERT INTO " . t_message . "(fromy,fromuid,touid,new,subject,time,content,status,type) VALUES ('" . $from . "'," . $fromuid . "," . $touid . ",1,'" . $subject . "','" . $time . "','" . $content . "',0,'".$type."')";
  61. $query = Doo::db ()->query ( $sql );
  62. }
  63. /**
  64. * 发布信息action
  65. */
  66. public function set_MESSAGE_ADD_QUESTION($title = "",$id=0) {
  67. return "问题 &nbsp;<a href=/askpage/".$id." >" . $title . "</a>&nbsp;新的问题";
  68. }
  69. /**
  70. * 发送名师已付款action
  71. */
  72. public function set_MESSAGE_ADD_VIP_PAID(){
  73. return "您对名师答疑进行了付费";
  74. }
  75. /**
  76. * 发送名师答疑问题设置成满意
  77. */
  78. public function set_MESSAGE_SET_VIP_SATISFY(){
  79. return "您对名师问题***设置为满意,并且退款机会为1次";
  80. }
  81. /**
  82. * 吧信息更新为已查看
  83. */
  84. public function update_message_new($uid=0){
  85. $sql = "UPDATE `" . t_message . "` SET `new` = '0' WHERE `new` = 1 and touid=".$uid." limit 30";
  86. $query = Doo::db ()->query ( $sql );
  87. }
  88. }
  89. ?>