<?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