B. srv / srvPasatiempoAgrega.php

1<?php
2
3require_once __DIR__ . "/../lib/php/ejecutaServicio.php";
4require_once __DIR__ . "/../lib/php/JsonResponse.php";
5require_once __DIR__ . "/../lib/php/leeTexto.php";
6require_once __DIR__ . "/modelo/Pasatiempo.php";
7require_once __DIR__ . "/bd/pasatiempoAgrega.php";
8
9ejecutaServicio(function () {
10 $nombre = leeTexto("nombre");
11 $modelo = new Pasatiempo(nombre: $nombre === null ? "" : trim($nombre));
12 pasatiempoAgrega($modelo);
13 $id = htmlentities($modelo->id);
14 return JsonResponse::created("/srv/srvPasatiempoBusca.php?id=$id", [
15 "id" => ["value" => $modelo->id],
16 "nombre" => ["value" => $modelo->nombre],
17 ]);
18});
19
skip_previous skip_next