123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- class commission_m extends Model
- {
- var $psize = 20;
- function __construct()
- {
- parent::Model();
- $this->psize = defined("SYS_PSIZE") ? SYS_PSIZE : 20;
- }
- function commission_m()
- {
- $this->__construct();
- }
- function get_one($id)
- {
- if(!$id)
- {
- return false;
- }
- $sql = "SELECT * FROM ".$this->db->prefix."commission WHERE id='".$id."'";
- $rs = $this->db->get_one($sql);
- if(!$rs) return false;
- return $rs;
- }
- function get_child_one($uid,$pid)
- {
- if(!$uid&&!$pid)
- {
- return false;
- }
- $sql = "SELECT * FROM ".$this->db->prefix."commission WHERE uid='".$uid."' and pid='".$pid."'";
- $rs = $this->db->get_one($sql);
- if(!$rs) return false;
- return $rs;
- }
- function get_list($offset=0,$condition="")
- {
- $sql = "SELECT * FROM ".$this->db->prefix."commission WHERE pid='0' ";
- if($condition)
- {
- $sql .= " and ".$condition;
- }
- $sql .= " ORDER BY id DESC LIMIT ".$offset.",".$this->psize;
- return $this->db->get_all($sql);
- }
- //取得总数量
- function get_count($condition="")
- {
- $sql = "SELECT count(id) FROM ".$this->db->prefix."commission WHERE pid='0' ";
- if($condition)
- {
- $sql .= " and ".$condition;
- }
- return $this->db->count($sql);
- }
- //存储会员数据
- function save($data,$id=0)
- {
- if($id)
- {
- $this->db->update_array($data,"commission",array("id"=>$id));
- return $id;
- }
- else
- {
- $insert_id = $this->db->insert_array($data,"commission");
- return $insert_id;
- }
- }
- function set_status($id,$status=0)
- {
- $sql = "UPDATE ".$this->db->prefix."commission SET status='".$status."' WHERE id='".$id."' or pid='".$id."'";
- return $this->db->query($sql);
- }
- function status($id,$status=0)
- {
- $sql = "UPDATE ".$this->db->prefix."commission SET status='".$status."' WHERE id IN(".$id.") or pid IN(".$id.") ";
- return $this->db->query($sql);
- }
- function delsub($id)
- {
- $sql = "DELETE FROM ".$this->db->prefix."commission WHERE pid='".$id."'";
- return $this->db->query($sql);
- }
- function del($id)
- {
- $sql = "DELETE FROM ".$this->db->prefix."commission WHERE id='".$id."' or pid='".$id."'";
- return $this->db->query($sql);
- }
- function pl_del($id)
- {
- $sql = "DELETE FROM ".$this->db->prefix."commission WHERE id IN(".$id.") or pid IN(".$id.")";
- return $this->db->query($sql);
- }
- }
- ?>
|