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/devuelveJson.php"; |
8 | require_once __DIR__ . "/../lib/php/ProblemDetails.php"; |
9 | require_once __DIR__ . "/Bd.php"; |
10 | require_once __DIR__ . "/TABLA_AMIGO.php"; |
11 | require_once __DIR__ . "/TABLA_PASATIEMPO.php"; |
12 | |
13 | ejecutaServicio(function () { |
14 | |
15 | $amiId = recuperaIdEntero("id"); |
16 | |
17 | $modelo = selectFirst(pdo: Bd::pdo(), from: AMIGO, where: [AMI_ID => $amiId]); |
18 | |
19 | if ($modelo === false) { |
20 | $amiIdHtml = htmlentities($amiId); |
21 | throw new ProblemDetails( |
22 | status: NOT_FOUND, |
23 | title: "Amigo no encontrado.", |
24 | type: "/error/amigonoencontrado.html", |
25 | detail: "No se encontró ningún amigo con el id $amiIdHtml.", |
26 | ); |
27 | } |
28 | |
29 | devuelveJson([ |
30 | "id" => ["value" => $amiId], |
31 | "nombre" => ["value" => $modelo[AMI_NOMBRE]], |
32 | "pasId" => ["value" => $modelo[PAS_ID] === null ? "" : $modelo[PAS_ID]] |
33 | ]); |
34 | }); |
35 | |