LotteryEventsVote.class.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 LotteryEventsVote extends DBAgileDev {
  14. protected $tableName = 'lottery_events_vote';
  15. /**
  16. * 数据库里的真实字段
  17. * @var array
  18. */
  19. protected $other_field = array(
  20. 'events_id',
  21. 'title',
  22. 'img_url',
  23. 'num',
  24. 'add_num'
  25. );
  26. /**
  27. * 获取当前活动的投票数据
  28. */
  29. public function getThisEventData($events_id){
  30. $condition = array(
  31. 'events_id' => $events_id
  32. );
  33. $ids = $this->findIdsBy($condition);
  34. if(!$ids){
  35. return null;
  36. }
  37. return $this->gets($ids);
  38. }
  39. /**
  40. * 投票数增加
  41. */
  42. public function upNum($id,$num=1){
  43. $data = $this->get($id);
  44. $info = array(
  45. 'num' => $data['num'] + $num
  46. );
  47. return $this->modify($info,array('id' => $id));
  48. }
  49. /**
  50. * 投票数递减
  51. * @param unknown $id
  52. * @param number $num
  53. * @return Ambigous <\KIF\Data\ResultWrapper, \KIF\Data\ResultWrapper>
  54. */
  55. public function decrNum($id, $num = 1) {
  56. $data = $this->get($id);
  57. $info = array(
  58. 'num' => $data['num'] - $num
  59. );
  60. return $this->modify($info,array('id' => $id));
  61. }
  62. }