/** * @param string $hallName * @return bool */ private function hallNameExists(string $hallName) : bool { $query = "SELECT id FROM halls WHERE name = ?"; $result = $this->db->prepare($query); $result->execute([$hallName]); return $result->rowCount() > 0; }
/** * @param int $id * @throws ApplicationException */ public function getById(int $id) { $query = "SELECT\n u.id,\n u.username,\n u.fullname\n FROM users AS u\n WHERE u.id = ?"; $result = $this->db->prepare($query); $result->execute([$id]); if ($result->rowCount() < 1) { throw new ApplicationException("User not found."); } return $result->fetch(); }
/** * @param string $conferenceTitle * @return bool */ private function conferenceTitleExists(string $conferenceTitle, int $id = -1) : bool { $query = "SELECT id FROM conferences WHERE title = ? AND id != ?"; $result = $this->db->prepare($query); $result->execute([$conferenceTitle, $id]); return $result->rowCount() > 0; }