-
-
Save parzibyte/a8c39852a25fff59cad7c8d2fc86286b 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 | |
include_once "base_de_datos.php"; | |
$consulta = "SELECT * FROM personas"; | |
# 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(); | |
# fecthObject va a devolver null alguna vez, cuando eso pase termina | |
# el ciclo | |
while ($persona = $sentencia->fetchObject()) { | |
// Aquí trabajar con persona, p.ej. $persona->nombre | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment