Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 5, 2019 18:11
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/0564e6e28454edc54680265474500a2d to your computer and use it in GitHub Desktop.
Save parzibyte/0564e6e28454edc54680265474500a2d to your computer and use it in GitHub Desktop.
<?php
include_once "base_de_datos.php";
$nombre = "Ejemplo";
$edad = 2;
/*
Al incluir el archivo "base_de_datos.php", todas sus variables están
a nuestra disposición. Por lo que podemos acceder a ellas tal como si hubiéramos
copiado y pegado el código
*/
$sentencia = $base_de_datos->prepare("INSERT INTO mascotas(nombre, edad) VALUES (?, ?);");
$resultado = $sentencia->execute([$nombre, $edad]); # Pasar en el mismo orden de los ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment