commission.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. class commission_m extends Model
  3. {
  4. var $psize = 20;
  5. function __construct()
  6. {
  7. parent::Model();
  8. $this->psize = defined("SYS_PSIZE") ? SYS_PSIZE : 20;
  9. }
  10. function commission_m()
  11. {
  12. $this->__construct();
  13. }
  14. function get_one($id)
  15. {
  16. if(!$id)
  17. {
  18. return false;
  19. }
  20. $sql = "SELECT * FROM ".$this->db->prefix."commission WHERE id='".$id."'";
  21. $rs = $this->db->get_one($sql);
  22. if(!$rs) return false;
  23. return $rs;
  24. }
  25. function get_child_one($uid,$pid)
  26. {
  27. if(!$uid&&!$pid)
  28. {
  29. return false;
  30. }
  31. $sql = "SELECT * FROM ".$this->db->prefix."commission WHERE uid='".$uid."' and pid='".$pid."'";
  32. $rs = $this->db->get_one($sql);
  33. if(!$rs) return false;
  34. return $rs;
  35. }
  36. function get_list($offset=0,$condition="")
  37. {
  38. $sql = "SELECT * FROM ".$this->db->prefix."commission WHERE pid='0' ";
  39. if($condition)
  40. {
  41. $sql .= " and ".$condition;
  42. }
  43. $sql .= " ORDER BY id DESC LIMIT ".$offset.",".$this->psize;
  44. return $this->db->get_all($sql);
  45. }
  46. //取得总数量
  47. function get_count($condition="")
  48. {
  49. $sql = "SELECT count(id) FROM ".$this->db->prefix."commission WHERE pid='0' ";
  50. if($condition)
  51. {
  52. $sql .= " and ".$condition;
  53. }
  54. return $this->db->count($sql);
  55. }
  56. //存储会员数据
  57. function save($data,$id=0)
  58. {
  59. if($id)
  60. {
  61. $this->db->update_array($data,"commission",array("id"=>$id));
  62. return $id;
  63. }
  64. else
  65. {
  66. $insert_id = $this->db->insert_array($data,"commission");
  67. return $insert_id;
  68. }
  69. }
  70. function set_status($id,$status=0)
  71. {
  72. $sql = "UPDATE ".$this->db->prefix."commission SET status='".$status."' WHERE id='".$id."' or pid='".$id."'";
  73. return $this->db->query($sql);
  74. }
  75. function status($id,$status=0)
  76. {
  77. $sql = "UPDATE ".$this->db->prefix."commission SET status='".$status."' WHERE id IN(".$id.") or pid IN(".$id.") ";
  78. return $this->db->query($sql);
  79. }
  80. function delsub($id)
  81. {
  82. $sql = "DELETE FROM ".$this->db->prefix."commission WHERE pid='".$id."'";
  83. return $this->db->query($sql);
  84. }
  85. function del($id)
  86. {
  87. $sql = "DELETE FROM ".$this->db->prefix."commission WHERE id='".$id."' or pid='".$id."'";
  88. return $this->db->query($sql);
  89. }
  90. function pl_del($id)
  91. {
  92. $sql = "DELETE FROM ".$this->db->prefix."commission WHERE id IN(".$id.") or pid IN(".$id.")";
  93. return $this->db->query($sql);
  94. }
  95. }
  96. ?>