-
-
Save parzibyte/1656285c81e8fda30ab1984782e4b8e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
CRUD con SQL Server y PHP | |
@author parzibyte [parzibyte.me/blog] | |
@date 2019-06-03 | |
================================ | |
Este archivo lista todos los | |
datos de la tabla, pero en un | |
ciclo usando un cursor, no | |
a través de un arreglo | |
(se supone que es más eficiente) | |
================================ | |
*/ | |
?> | |
<?php | |
include_once "base_de_datos.php"; | |
$consulta = "select id, nombre, edad from mascotas"; | |
# Preparar sentencia e indicar que vamos a usar un cursor | |
$sentencia = $base_de_datos->prepare($consulta, [ | |
PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL, | |
]); | |
# Ejecutar sin parámetros | |
$sentencia->execute(); | |
# Forma de iterar | |
while ($mascota = $sentencia->fetchObject()){ | |
# Aquí hacer algo con $mascota | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment