public function getUserByUsername($username) { try { $db = $this->connection(); $sql = "SELECT * FROM " . self::$dbTable . " WHERE " . self::$userName . " = ?"; $params = array($username); $query = $db->prepare($sql); $query->execute($params); $result = $query->fetch(); if ($result) { $user = new User(); $user->SetUsername($result[self::$userName]); $user->SetHash($result[self::$password]); $user->SetUserID($result[self::$userID]); return $user; } else { return NULL; } } catch (\PDOException $e) { throw new \Exception(); } }
public function GetUniqueKey($uniqueKey) { try { $db = $this->connection(); $sql = "SELECT * FROM " . self::$dbTable . " WHERE " . self::$uniqueKey . " = ?"; $params = array($uniqueKey); $query = $db->prepare($sql); $query->execute($params); $result = $query->fetch(); if ($result) { $user = new User(); // Set my UserID and Expire to my dbUserModel. $user->SetUserID($result[self::$userID]); $user->SetExpire($result[self::$expire]); return $user; } else { return NULL; } } catch (\PDOException $e) { throw new \Exception(); } }