con = $con; } public function get(int $id): ?TacticInfo { $res = $this->con->fetch( "SELECT * FROM TacticInfo WHERE id = :id", [":id" => [$id, PDO::PARAM_INT]] ); if (!isset($res[0])) { return null; } $row = $res[0]; return new TacticInfo($id, $row["name"], strtotime($row["creation_date"])); } public function insert(string $name): TacticInfo { $this->con->exec( "INSERT INTO TacticInfo(name) VALUES(:name)", [":name" => [$name, PDO::PARAM_STR]] ); $row = $this->con->fetch( "SELECT id, creation_date FROM TacticInfo WHERE :id = id", [':id' => [$this->con->lastInsertId(), PDO::PARAM_INT]] )[0]; return new TacticInfo(intval($row["id"]), $name, strtotime($row["creation_date"])); } public function updateName(int $id, string $name) { $this->con->exec( "UPDATE TacticInfo SET name = :name WHERE id = :id", [ ":name" => [$name, PDO::PARAM_STR], ":id" => [$id, PDO::PARAM_INT] ] ); } }