id = (int) $id; $this->date = DateTime::createFromFormat('Y-m-d', $date); $this->shiaiId = (($shiaiId != null) ? ((int)$shiaiId) : (null)); $this->deadline = DateTime::createFromFormat('Y-m-d', $deadline); $this->remarks = $remarks; $this->shiai = $shiai; } public static function loadFromDb(int $id) { $query = 'SELECT * FROM `cwsvjudo`.`wkParticipo_Events` WHERE `id` = :id;'; $params = [':id' => ['value' => $id, 'data_type' => PDO::PARAM_INT]]; $response = dbConnector::query($query, $params); // ids are considered unique. so every other count then 1 is treated as error to prevent unprivileged access if (count($response) != 1) { return null; } return Event::fromDbArray($response[0]); } /** Representation of an event as (materializeCss) card * * @return string string with the html code of the event */ public function asHtmlCard() { return '