Message.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Message extends Model
  5. {
  6. public $page_info;
  7. /**
  8. * 添加留言
  9. * @param type $param
  10. * @return type
  11. */
  12. public function addMessage($param)
  13. {
  14. return db('message')->insertGetId($param);
  15. }
  16. /**
  17. * 删除留言
  18. * @param unknown $condition
  19. * @return boolean
  20. */
  21. public function delMessage($condition)
  22. {
  23. return db('message')->where($condition)->delete();
  24. }
  25. /*
  26. * 回复留言
  27. */
  28. public function editMessage($condition, $update)
  29. {
  30. return db('message')->where($condition)->update($update);
  31. }
  32. /*
  33. * 留言列表
  34. */
  35. public function getMessageList($condition, $field = '*', $page = 0, $order = 'message_addtime asc, message_id desc', $limit = '')
  36. {
  37. if ($limit) {
  38. return db('message')->where($condition)->field($field)->order($order)->page($page)->limit($limit)->select();
  39. } else {
  40. $res = db('message')->where($condition)->field($field)->order($order)->paginate($page);
  41. $this->page_info = $res;
  42. return $res->items();
  43. }
  44. }
  45. /**
  46. * 取单个留言内容
  47. */
  48. public function getOneMessage($condition, $field = '*')
  49. {
  50. return db('message')->field($field)->where($condition)->find();
  51. }
  52. }
  53. ?>