userModel.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <?php
  2. class userModel extends Staple_Model
  3. {
  4. private $db;
  5. private $id;
  6. private $username;
  7. private $firstName;
  8. private $lastName;
  9. private $accountType;
  10. private $batchId;
  11. /**
  12. * @return mixed
  13. */
  14. public function getId()
  15. {
  16. return $this->id;
  17. }
  18. /**
  19. * @param mixed $id
  20. */
  21. public function setId($id)
  22. {
  23. $this->id = $id;
  24. }
  25. /**
  26. * @return mixed
  27. */
  28. public function getUsername()
  29. {
  30. return $this->username;
  31. }
  32. /**
  33. * @param mixed $username
  34. */
  35. public function setUsername($username)
  36. {
  37. $this->username = $username;
  38. }
  39. /**
  40. * @return mixed
  41. */
  42. public function getFirstName()
  43. {
  44. return $this->firstName;
  45. }
  46. /**
  47. * @param mixed $firstName
  48. */
  49. public function setFirstName($firstName)
  50. {
  51. $this->firstName = $firstName;
  52. }
  53. /**
  54. * @return mixed
  55. */
  56. public function getLastName()
  57. {
  58. return $this->lastName;
  59. }
  60. /**
  61. * @param mixed $lastName
  62. */
  63. public function setLastName($lastName)
  64. {
  65. $this->lastName = $lastName;
  66. }
  67. /**
  68. * @return mixed
  69. */
  70. public function getAccountType()
  71. {
  72. return $this->accountType;
  73. }
  74. /**
  75. * @param mixed $accountType
  76. */
  77. public function setAccountType($accountType)
  78. {
  79. $this->accountType = $accountType;
  80. }
  81. /**
  82. * @return mixed
  83. */
  84. public function getBatchId()
  85. {
  86. return $this->batchId;
  87. }
  88. /**
  89. * @param mixed $batchId
  90. */
  91. public function setBatchId($batchId)
  92. {
  93. $this->batchId = $batchId;
  94. }
  95. function __construct()
  96. {
  97. $this->db = Staple_DB::get();
  98. $auth = Staple_Auth::get();
  99. $username = $auth->getAuthId();
  100. $sql = "SELECT id, username, firstName, lastName, accountType, batchId FROM accounts WHERE username = '".$this->db->real_escape_string($username)."'";
  101. if($this->db->query($sql)->fetch_row() > 0)
  102. {
  103. $query = $this->db->query($sql);
  104. $result = $query->fetch_assoc();
  105. $this->setid($result['id']);
  106. $this->setUsername($result['username']);
  107. $this->setFirstName($result['firstName']);
  108. $this->setLastName($result['lastName']);
  109. $this->setAccountType($result['accountType']);
  110. $this->setBatchId($result['batchId']);
  111. }
  112. else
  113. {
  114. return false;
  115. }
  116. }
  117. }
  118. ?>