Skip to content

Instantly share code, notes, and snippets.

Created September 19, 2019 18:29
What would you like to do?
public function read($id_de_sesion)
$sentencia = $this->base_de_datos->prepare("SELECT datos FROM sesiones WHERE id = ?;");
# 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