users.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. Doo::loadCore('db/DooModel');
  3. class Users extends DooModel {
  4. public $id;
  5. public $username;
  6. public $useremail;
  7. public $userpasswd;
  8. public $userquestion;
  9. public $defquestion;
  10. public $useranswer;
  11. public $actstate;
  12. public $salt;
  13. public $regip;
  14. public $regdate;
  15. public $lastloginip;
  16. public $lastlogintime;
  17. public $lastip;
  18. public $uptime;
  19. public $intime;
  20. public $bank;
  21. public $mobile;
  22. public $keys_auth;
  23. public $_table = 'zh_users';
  24. public $_primarykey = 'id';
  25. public $_fields = array('id', 'username', 'useremail', 'userpasswd', 'userquestion', 'defquestion', 'useranswer', 'actstate', 'salt', 'regip', 'regdate', 'lastloginip', 'lastlogintime', 'lastip', 'uptime', 'intime', 'bank', 'mobile','keys_auth');
  26. public function __construct() {
  27. parent::setupModel(__CLASS__);
  28. }
  29. /**
  30. *
  31. * @param type $param
  32. */
  33. public function userAdd($uArray) {
  34. if (!is_array($uArray))
  35. return FALSE;
  36. $this->username = $uArray['username'];
  37. $this->useremail = $uArray['useremail'];
  38. $this->userpasswd = $uArray['userpasswd'];
  39. $this->actstate = 0;
  40. $this->regip = $uArray['clientip'];
  41. $this->intime = time();
  42. $this->salt = $uArray['salt'];
  43. return $this->insert();
  44. }
  45. /**
  46. *
  47. * @param type $param
  48. */
  49. public function getAll($limit) {
  50. return $this->find(array('select' => 'id,username,mobile,useremail,lastloginip,lastlogintime', 'desc' => 'regdate', 'limit' => $limit, 'asArray' => TRUE));
  51. }
  52. /**
  53. *
  54. * @param type $param
  55. */
  56. public function getCountz() {
  57. return $this->count();
  58. }
  59. /**
  60. *
  61. * @param type $param
  62. */
  63. public function updateBank($uid, $money) {
  64. $this->bank = new DooDbExpression('bank+' . $money);
  65. return $this->update(array('where' => 'id=' . $uid));
  66. }
  67. public function getRowByUid($uid) {
  68. if (empty($uid))
  69. return false;
  70. return $this->find(array('select' => 'bank,username,useremail', 'where' => 'id=' . $uid, 'asArray' => TRUE));
  71. }
  72. public function getRowByMobile($mobile) {
  73. return $this->getOne(array('where' => 'mobile="' . $mobile . '"', 'asArray' => TRUE));
  74. }
  75. public function getRowByName($name) {
  76. return $this->getOne(array('where' => 'username="' . $name . '"', 'asArray' => TRUE));
  77. }
  78. public function getRowByid($uid) {
  79. return $this->getOne(array('select' => 'mobile,useremail', 'where' => 'id=' . $uid, 'asArray' => TRUE));
  80. }
  81. public function getidBysearch($search) {
  82. return $this->getOne(array('select' => 'id' ,'where' => 'username=? or useremail=? or mobile=?', 'param' => array($search,$search,$search), 'asArray' => TRUE));
  83. }
  84. }
  85. ?>