1If we had a value:
2
3$sql = "SELECT * FROM myTable WHERE id = ?";
4$stmt = $conn->prepare($sql);
5$stmt->bindValue(1,1);
6$stmt->execute();
7
8If we had two values:
9
10$sql = "SELECT * FROM myTable WHERE id = ? and name = ?";
11$stmt = $conn->prepare($sql);
12$stmt->bindValue(1,1);
13$stmt->bindValue(2,"alireza");
14$stmt->execute();
1$sql = "SELECT * FROM myTable WHERE id = ?";
2$stmt = $conn->prepare($sql);
3$stmt->execute([$id]);
1$sql = "SELECT * FROM myTable WHERE id = :id";
2$stmt = $conn->prepare($sql);
3$stmt->execute([":id"=>$id]);