0
Hello, I have this code:
<<?php
include("conexao.php");
$pdo = conectar();
$buscarusuario = $pdo->prepare("SELECT * FROM tab_clientes WHERE ID=:id");
$buscarusuario->bindValue(":id",2,PDO::PARAM_INT);
$buscarusuario->execute();
$linha = $buscarusuario->fetchAll(PDO::FETCH_OBJ);
foreach ($linha as $listar) {
echo "E-mail: ".$listar->email."</br>";
var_dump($listar);
}
My problem is that the echo
is not displayed on the screen, tested with the var_dump
and it shows the BD data. Using FETCH_ASSOC
normal, but since I’m learning PDO, I wanted to do this using the FETCH_OBJ
, however, as I said, echo
is not displayed on the screen. Does anyone have an idea of why this occurs or what other way to display? I thank you in advance!
So it worked, thank you very much, but just one more thing, because I’m treating the variable as an object, because I’m using
FETCH_OBJ
, theforeach
cannot be applied?– Arthur Oliveira