12345678910111213141516171819202122 |
- <?php
- class UserDataCache {
- public static function getInstance() {
- return new UserDataCache(new mysqli(DB_HOST, DB_USER, DB_PASS, DATABASE));
- }
- private $db;
- private function __construct(mysqli $db) {
- $this->db = $db;
- }
- public function getUserById($userId) {
- }
- public function getUserByLogin($email, $password) {
- $sql = sprintf("SELECT user_id FROM users WHERE email = '%s' AND password = md5('%s') LIMIT 1", $email, $password);
- $result = $this->db->query($sql);
- if(!$result) {
- return false;
- }
-
- $userData = $result->fetch_assoc();
- return $userData;
- }
- }
|