inviteDao.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. *
  4. * @author Deben Chen
  5. *
  6. */
  7. class inviteDao extends commonDao
  8. {
  9. public $table_name = 'invite_code';
  10. protected $fields = "id,code,user,status,platform";
  11. /**
  12. * 取邀请码
  13. *
  14. * @param unknown $id
  15. */
  16. public function getOneByInvite($code)
  17. {
  18. return $this->dao->db->get_one_by_field(array(
  19. 'code' => $code
  20. ), $this->table_name);
  21. }
  22. /**
  23. * 删除邀请码
  24. *
  25. * @param unknown $code
  26. * @return boolean
  27. */
  28. public function delete($code)
  29. {
  30. $this->getDb()->update_by_field(array(
  31. 'status' => 0
  32. ), array(
  33. 'code' => $code
  34. ), $this->table_name);
  35. // return $this->dao->db->delete_by_field(array('code'=>$code), $this->table_name);
  36. }
  37. /**
  38. * 添加邀请码
  39. *
  40. * @param unknown $data
  41. */
  42. public function add($data)
  43. {
  44. return parent::add($data);
  45. // $data=$this->dao->db->build_key($data, $this->fields);
  46. // return $this->dao->db->insert($data, $this->table_name);
  47. }
  48. /**
  49. * 获取所有的邀请码
  50. *
  51. * @return Ambigous <number, multitype:multitype: >
  52. */
  53. public function getAll()
  54. {
  55. return parent::getAll(array(
  56. 'status'=>1,
  57. 'platform'=>'shadowsocks5'
  58. ));
  59. // $result=$this->dao->db->get_all($this->table_name);
  60. // return $result[0];
  61. }
  62. }