inform_subject.model.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * 举报主题模型
  4. *
  5. *
  6. *
  7. *
  8. */
  9. defined('InShopNC') or exit('Access Invalid!');
  10. class inform_subjectModel{
  11. /*
  12. * 构造条件
  13. */
  14. private function getCondition($condition){
  15. $condition_str = '' ;
  16. if(!empty($condition['inform_subject_state'])) {
  17. $condition_str .= " and inform_subject_state = '{$condition['inform_subject_state']}'";
  18. }
  19. if(!empty($condition['inform_subject_type_id'])) {
  20. $condition_str .= " and inform_subject_type_id = '{$condition['inform_subject_type_id']}'";
  21. }
  22. if(!empty($condition['in_inform_subject_id'])) {
  23. $condition_str .= " and inform_subject_id in (".$condition['in_inform_subject_id'].')';
  24. }
  25. if(!empty($condition['in_inform_subject_type_id'])) {
  26. $condition_str .= " and inform_subject_type_id in (".$condition['in_inform_subject_type_id'].')';
  27. }
  28. return $condition_str;
  29. }
  30. /*
  31. * 增加
  32. * @param array $param
  33. * @return bool
  34. */
  35. public function saveInformSubject($param){
  36. return Db::insert('inform_subject',$param) ;
  37. }
  38. /*
  39. * 更新
  40. * @param array $update_array
  41. * @param array $where_array
  42. * @return bool
  43. */
  44. public function updateInformSubject($update_array, $where_array){
  45. $where = $this->getCondition($where_array) ;
  46. return Db::update('inform_subject',$update_array,$where) ;
  47. }
  48. /*
  49. * 删除
  50. * @param array $param
  51. * @return bool
  52. */
  53. public function dropInformSubject($param){
  54. $where = $this->getCondition($param) ;
  55. return Db::delete('inform_subject', $where) ;
  56. }
  57. /*
  58. * 获得列表
  59. * @param array $condition
  60. * @param obj $page //分页对象
  61. * @return array
  62. */
  63. public function getInformSubject($condition='',$page='',$field=''){
  64. $param = array() ;
  65. $param['table'] = 'inform_subject' ;
  66. $param['field'] = $field;
  67. $param['where'] = $this->getCondition($condition);
  68. $param['order'] = $condition['order'] ? $condition['order']: ' inform_subject_id desc ';
  69. return Db::select($param,$page) ;
  70. }
  71. }