config = $_SESSION['database_configuration']; } /** * @throws GenericErrorException */ public function createConnection(): void { try { $this->conn = new mysqli($this->config['dsn'], $this->config['user'], $this->config['password'], $this->config['dbname']); } catch (Exception){ throw new GenericErrorException(); } } /** * @throws UserNotExistingException */ public function executeReq(array $body): int|string { $email = $body["email"]; $password = $body["password"]; $query = "SELECT id FROM Users WHERE email = '$email' AND password = '$password'"; $result = $this->conn->query($query); if(!$result->num_rows) throw new UserNotExistingException(); $row = mysqli_fetch_row($result); return $row[0]; } }