LotteryUserParticipateLog.class.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. );
  24. public function findUserParticipateDataGroupByUid($eventsId,$limit=null){
  25. $sql = "SELECT uid,create_time FROM `{$this->tableName}` WHERE events_id={$eventsId} GROUP BY uid ";
  26. if($limit){
  27. $sql = "SELECT uid,create_time FROM `{$this->tableName}` WHERE events_id={$eventsId} GROUP BY uid limit {$limit} ";
  28. }
  29. $tmpResult = $this->db->fetchAll($sql);
  30. if (!$tmpResult) {
  31. return array();
  32. }
  33. return $tmpResult;
  34. }
  35. public function getUserParticipateLogNumGroupByUid($eventsId){
  36. $returnNum = 0;
  37. $sql = "SELECT count(uid) FROM `{$this->tableName}` WHERE events_id={$eventsId} GROUP BY uid ";
  38. $tmpResult = $this->db->fetchAll($sql);
  39. if (!$tmpResult) {
  40. return $returnNum;
  41. }
  42. return count($tmpResult);
  43. }
  44. }