I'm trying to make a query with sql under one criterion
Well, let me introduce the code.
include_once "conexion.php";
/* Ejecuta una sentencia preparada pasando un array de valores */
$id = 1;
$sql = "SELECT * FROM users WHERE Id = :Id";
$statement = $pdo->prepare($sql);
if(!$statement){
echo "ERROR:".PHP_EOL;
print_r($pdo->errorInfo());
}else{
$statement->execute([':Id'=> 1]);
$result = $statement->fetchAll();
var_dump($result); var_dump($statement);
}
var_dump($result);
The result does not throw me anything,
And apparently no value is returned to me, but if I try with the name criteria, it returns the value I expect.
I'm suspecting that the problem is in the condition using the id since it does not return anything to me.
I hope your help thanks.
I have removed the single quotes from the sql criterion but they still do not return a value to me.
By testing the value I get with var_dump this returns this:
array (size=0)
empty
THE CODES ARE ALREADY UPDATED, AND AS SEEN IT CONTINUES WITHOUT WORKING
C:\xampp\htdocs\proyecto\select2.php:19:
array (size=0)
empty
C:\xampp\htdocs\proyecto\select2.php:19:
object(PDOStatement)[2]
public 'queryString' => string 'SELECT * FROM users WHERE Id = :Id' (length=35)
C:\xampp\htdocs\proyecto\select2.php:21:
array (size=0)
empty
1
Try the recommendation, adding the following in the code.