Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 5, 2019 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/02a7c1a9dc0291766e182eaf2607f5d9 to your computer and use it in GitHub Desktop.
Save parzibyte/02a7c1a9dc0291766e182eaf2607f5d9 to your computer and use it in GitHub Desktop.
<?php
$id = 1;
include_once "base_de_datos.php";
$sentencia = $base_de_datos->prepare("SELECT id, nombre, edad FROM mascotas WHERE id = ?;");
$sentencia->execute([$id]);
$mascota = $sentencia->fetchObject();
if (!$mascota) {
#No existe
echo "¡No existe alguna mascota con ese ID!";
exit();
}
#Si la mascota existe, se ejecuta esta parte del código
# Aquí hacer algo con $mascota...
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment