micro_personal.model.php 2.4 KB

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