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 | |
public function read($id_de_sesion) | |
{ | |
$sentencia = $this->base_de_datos->prepare("SELECT datos FROM sesiones WHERE id = ?;"); | |
$sentencia->execute([$id_de_sesion]); | |
# Recuperar como objeto (con PDO::FETCH_OBJ), para acceder a $fila->datos | |
$fila = $sentencia->fetch(PDO::FETCH_OBJ); | |
# Si no existen datos con ese id, fetch devuelve FALSE | |
if ($fila === false) { | |
return ""; # Cadena vacía | |
} else { | |
return $fila->datos; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment