leaderboard.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. class leaderboard_m extends Model
  3. {
  4. function __construct()
  5. {
  6. parent::Model();
  7. }
  8. function leaderboard_m()
  9. {
  10. $this->__construct();
  11. }
  12. function get_list($offset=0,$psize=30)
  13. {
  14. $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;
  15. //$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";
  16. return $this->db->get_all($sql);
  17. }
  18. function get_count()
  19. {
  20. $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";
  21. return $this->db->count($sql);
  22. }
  23. function customer_from_id($id)
  24. {
  25. $this->db->close_cache();
  26. $sql = "SELECT * FROM ".$this->db->prefix."customer WHERE id='".$id."'";
  27. $rs = $this->db->get_one($sql);
  28. if(!$rs) return false;
  29. $this->db->open_cache();
  30. return $rs;
  31. }
  32. }
  33. ?>