LotteryEventsUserLetters.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Cas\Dao;
  3. use KIF\Dao\DBAgileDev;
  4. use KIF\Core\Request;
  5. /**
  6. *
  7. * 活动[用户收集字母信息]
  8. *
  9. * @author lihuanchun@qq.com
  10. *
  11. */
  12. class LotteryEventsUserLetters extends DBAgileDev {
  13. protected $tableName = 'lottery_events_user_letters';
  14. /**
  15. * 数据库里的真实字段
  16. * @var array
  17. */
  18. protected $other_field = array(
  19. 'events_id',
  20. 'uid',
  21. );
  22. /**
  23. * 获取一个用户的收集信息
  24. */
  25. public function getOneUserData($events_id,$uid){
  26. $condition = array(
  27. 'events_id' => $events_id,
  28. 'uid' => $uid,
  29. );
  30. $ids = $this-> findIdsBy($condition);
  31. $data = $this-> gets($ids);
  32. return array_shift($data);
  33. }
  34. /**
  35. * 添加一个提字母
  36. * array(
  37. * 'events_id' =>
  38. * 'uid' =>
  39. * 'ABC_data' => letters_id
  40. * )
  41. */
  42. public function addLetters($info){
  43. $condition = array(
  44. 'events_id' => $info['events_id'],
  45. 'uid' => $info['uid'],
  46. );
  47. $ids = $this-> findIdsBy($condition);
  48. $data = $this-> gets($ids);
  49. $data = array_shift($data);
  50. if(empty($data)){
  51. $ABC_data = $info['ABC_data'];
  52. $info['ABC_data'] = array($ABC_data => $ABC_data);
  53. return $this->add($info);
  54. }else{
  55. $data['ABC_data'][$info['ABC_data']] = $info['ABC_data'];
  56. $new_info = array(
  57. 'ABC_data' => $data['ABC_data'],
  58. );
  59. return $this->modify($new_info,array('id' => $data['id']));
  60. }
  61. }
  62. }