/** * This function allows to get a pad by ID * * @param integer $padId * @return PadComponent The pad associated with the ID */ public static function getByPadID($padID) { $padGuests = PadGuestComponent::getByPadID($padID); $guests = array(); if (count($padGuests) > 0) { foreach ($padGuests as $padGuestid => $padGuest) { $guests[] = new self(self::getByID($padGuest->guest_id)); } } return $guests; }
/** * This function allwso to know if current pad has guest passed in parameters * * @param GuestComponent $guest * @return boolean true if has,n false otherwhise */ public function hasGuest($guest) { $tmpGuest = GuestComponent::getByEmail($guest->email); if ($tmpGuest) { $query = 'SELECT * FROM ' . PadGuestComponent::getDBTable() . " where pad_id = :pad_id AND guest_id = :guest_id "; $statement = DBI::prepare($query); $statement->execute(array('pad_id' => $this->id, 'guest_id' => $guest->id)); $datas = $statement->fetch(); if (is_array($datas)) { return true; } } return false; }