cms_comment.model.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * CMS评论模型
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class cms_commentModel extends Model{
  11. public function __construct(){
  12. parent::__construct('cms_comment');
  13. }
  14. /**
  15. * 读取列表
  16. * @param array $condition
  17. *
  18. */
  19. public function getList($condition,$page='',$order='',$field='*'){
  20. $result = $this->table('cms_comment')->field($field)->where($condition)->page($page)->order($order)->select();
  21. return $result;
  22. }
  23. /**
  24. * 读取用户信息
  25. *
  26. */
  27. public function getListWithUserInfo($condition, $page='', $order='', $field='*'){
  28. $on = 'cms_comment.comment_member_id = member.member_id';
  29. $result = $this->table('cms_comment,member')->field($filed)->join('left')->on($on)->where($condition)->page($page)->order($order)->select();
  30. return $result;
  31. }
  32. /**
  33. * 读取单条记录
  34. * @param array $condition
  35. *
  36. */
  37. public function getOne($condition){
  38. $result = $this->where($condition)->find();
  39. return $result;
  40. }
  41. /*
  42. * 判断是否存在
  43. * @param array $condition
  44. *
  45. */
  46. public function isExist($condition) {
  47. $result = $this->getOne($condition);
  48. if(empty($result)) {
  49. return FALSE;
  50. }
  51. else {
  52. return TRUE;
  53. }
  54. }
  55. /*
  56. * 增加
  57. * @param array $param
  58. * @return bool
  59. */
  60. public function save($param){
  61. return $this->insert($param);
  62. }
  63. /*
  64. * 增加
  65. * @param array $param
  66. * @return bool
  67. */
  68. public function saveAll($param){
  69. return $this->insertAll($param);
  70. }
  71. /*
  72. * 更新
  73. * @param array $update
  74. * @param array $condition
  75. * @return bool
  76. */
  77. public function modify($update, $condition){
  78. return $this->where($condition)->update($update);
  79. }
  80. /*
  81. * 删除
  82. * @param array $condition
  83. * @return bool
  84. */
  85. public function drop($condition){
  86. return $this->where($condition)->delete();
  87. }
  88. }