UserDataCache.php 581 B

12345678910111213141516171819202122
  1. <?php
  2. class UserDataCache {
  3. public static function getInstance() {
  4. return new UserDataCache(new mysqli(DB_HOST, DB_USER, DB_PASS, DATABASE));
  5. }
  6. private $db;
  7. private function __construct(mysqli $db) {
  8. $this->db = $db;
  9. }
  10. public function getUserById($userId) {
  11. }
  12. public function getUserByLogin($email, $password) {
  13. $sql = sprintf("SELECT user_id FROM users WHERE email = '%s' AND password = md5('%s') LIMIT 1", $email, $password);
  14. $result = $this->db->query($sql);
  15. if(!$result) {
  16. return false;
  17. }
  18. $userData = $result->fetch_assoc();
  19. return $userData;
  20. }
  21. }