You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UserManager.php 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace SCF\Core;
  3. class UserManager {
  4. /**
  5. * @var mixed
  6. */
  7. private $_db;
  8. /**
  9. * @var int $userId
  10. */
  11. private $userId;
  12. /**
  13. * @var array
  14. */
  15. private $userData = [];
  16. /**
  17. * UserManager constructor.
  18. * @param Database $db
  19. * @param $userId
  20. */
  21. public function __construct(Database $db, $userId)
  22. {
  23. $this->_db = $db;
  24. $this->userId = $userId;
  25. $this->getPlayerAccount($this->userId);
  26. }
  27. /**
  28. * @param $userId
  29. */
  30. private function getPlayerAccount($userId)
  31. {
  32. $this->_db->query("SELECT * FROM users WHERE userId = :userId LIMIT 0,1");
  33. $this->_db->bind(':userId', $userId);
  34. $this->userData = $this->_db->single();
  35. }
  36. /**
  37. * @param $value
  38. * @return mixed|string
  39. */
  40. public function getValue($value)
  41. {
  42. if(isset($this->userData[$value])) {
  43. return $this->userData[$value];
  44. } else {
  45. return 'N/A';
  46. }
  47. }
  48. }