| 1 | <?php |
| 2 | |
| 3 | require_once __DIR__ . "/lib/manejaErrores.php"; |
| 4 | require_once __DIR__ . "/lib/recibeEnteroObligatorio.php"; |
| 5 | require_once __DIR__ . "/lib/recibeTextoObligatorio.php"; |
| 6 | require_once __DIR__ . "/lib/recibeEnteroOpcional.php"; |
| 7 | require_once __DIR__ . "/lib/devuelveJson.php"; |
| 8 | require_once __DIR__ . "/Bd.php"; |
| 9 | require_once __DIR__ . "/pasatiempoOptions.php"; |
| 10 | |
| 11 | $id = recibeEnteroObligatorio("id"); |
| 12 | $nombre = recibeTextoObligatorio("nombre"); |
| 13 | $pasId = recibeEnteroOpcional("pasId"); |
| 14 | |
| 15 | $bd = Bd::pdo(); |
| 16 | $stmt = $bd->prepare( |
| 17 | "UPDATE AMIGO |
| 18 | SET |
| 19 | AMI_NOMBRE = :AMI_NOMBRE, |
| 20 | PAS_ID = :PAS_ID |
| 21 | WHERE |
| 22 | AMI_ID = :AMI_ID" |
| 23 | ); |
| 24 | $stmt->execute([ |
| 25 | ":AMI_NOMBRE" => $nombre, |
| 26 | ":PAS_ID" => $pasId, |
| 27 | ":AMI_ID" => $id, |
| 28 | ]); |
| 29 | |
| 30 | devuelveJson([ |
| 31 | "id" => ["value" => $id], |
| 32 | "nombre" => ["value" => $nombre], |
| 33 | "pasId" => [ |
| 34 | "innerHTML" => pasatiempoOptons(), |
| 35 | "value" => $pasId === null ? "" : $pasId |
| 36 | ] |
| 37 | ]); |
| 38 | |