LotteryUserParticipateLog.class.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace Cas\Dao;
  3. use KIF\Dao\DBAgileDev;
  4. use KIF\Core\Request;
  5. use KIF\Cache\Memcached;
  6. /**
  7. *
  8. * 活动用户参与日志
  9. *
  10. * @author lihuanchun@qq.com
  11. *
  12. */
  13. class LotteryUserParticipateLog extends DBAgileDev {
  14. protected $tableName = 'lottery_user_participate_log';
  15. /**
  16. * 数据库里的真实字段
  17. *
  18. * @var array
  19. */
  20. protected $other_field = array (
  21. 'events_id',
  22. 'uid',
  23. # 审核字段 1未审核 2审核通过 3审核不通过
  24. 'audit',
  25. );
  26. public function findUserParticipateDataGroupByUid($eventsId,$limit=null){
  27. $sql = "SELECT uid,create_time FROM `{$this->tableName}` WHERE events_id={$eventsId} GROUP BY uid ";
  28. if($limit){
  29. $sql = "SELECT uid,create_time FROM `{$this->tableName}` WHERE events_id={$eventsId} GROUP BY uid limit {$limit} ";
  30. }
  31. $tmpResult = $this->db->fetchAll($sql);
  32. if (!$tmpResult) {
  33. return array();
  34. }
  35. return $tmpResult;
  36. }
  37. public function getUserParticipateLogNumGroupByUid($eventsId){
  38. $returnNum = 0;
  39. $sql = "SELECT count(uid) FROM `{$this->tableName}` WHERE events_id={$eventsId} GROUP BY uid ";
  40. $tmpResult = $this->db->fetchAll($sql);
  41. if (!$tmpResult) {
  42. return $returnNum;
  43. }
  44. return count($tmpResult);
  45. }
  46. }