123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- class leaderboard_m extends Model
- {
- function __construct()
- {
- parent::Model();
- }
- function leaderboard_m()
- {
- $this->__construct();
- }
- function get_list($offset=0,$psize=30)
- {
- $sql = "SELECT id,username, (SELECT SUM(money) from ".$this->db->prefix."commission where uid=".$this->db->prefix."user.id) as sumMoney,(SELECT count(id) from ".$this->db->prefix."customer where uid=".$this->db->prefix."user.id) as sumCount FROM ".$this->db->prefix."user ORDER BY sumMoney DESC,sumCount DESC,id DESC LIMIT ".$offset.",".$psize;
- //$sql="SELECT id,username, (SELECT SUM(money) from lyfz_commission where uid=lyfz_user.id) as sumMoney,(SELECT SUM(id) from lyfz_customer where uid=lyfz_user.id) as sumCount from lyfz_user ORDER BY sumMoney DESC,sumCount desc";
- return $this->db->get_all($sql);
- }
- function get_count()
- {
- $sql = "SELECT id,username, (SELECT SUM(money) from ".$this->db->prefix."commission where uid=".$this->db->prefix."user.id) as sumMoney,(SELECT SUM(id) from ".$this->db->prefix."customer where uid=".$this->db->prefix."user.id) as sumCount FROM ".$this->db->prefix."user ORDER BY sumMoney DESC,sumCount DESC";
- return $this->db->count($sql);
- }
- function customer_from_id($id)
- {
- $this->db->close_cache();
- $sql = "SELECT * FROM ".$this->db->prefix."customer WHERE id='".$id."'";
- $rs = $this->db->get_one($sql);
- if(!$rs) return false;
- $this->db->open_cache();
- return $rs;
- }
- }
- ?>
|