| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/../lib/php/NOT_FOUND.php"; |
| 4 | require_once __DIR__ . "/../lib/php/ejecutaServicio.php"; |
| 5 | require_once __DIR__ . "/../lib/php/recuperaIdEntero.php"; |
| 6 | require_once __DIR__ . "/../lib/php/selectFirst.php"; |
| 7 | require_once __DIR__ . "/../lib/php/ProblemDetails.php"; |
| 8 | require_once __DIR__ . "/../lib/php/devuelveJson.php"; |
| 9 | require_once __DIR__ . "/Bd.php"; |
| 10 | require_once __DIR__ . "/TABLA_PASATIEMPO.php"; |
| 11 | |
| 12 | ejecutaServicio(function () { |
| 13 | |
| 14 | $id = recuperaIdEntero("id"); |
| 15 | |
| 16 | $modelo = |
| 17 | selectFirst(pdo: Bd::pdo(), from: PASATIEMPO, where: [PAS_ID => $id]); |
| 18 | |
| 19 | if ($modelo === false) { |
| 20 | $idHtml = htmlentities($id); |
| 21 | throw new ProblemDetails( |
| 22 | status: NOT_FOUND, |
| 23 | title: "Pasatiempo no encontrado.", |
| 24 | type: "/error/pasatiemponoencontrado.html", |
| 25 | detail: "No se encontró ningún pasatiempo con el id $idHtml.", |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | devuelveJson([ |
| 30 | "id" => ["value" => $id], |
| 31 | "nombre" => ["value" => $modelo[PAS_NOMBRE]], |
| 32 | ]); |
| 33 | }); |
| 34 | |