bind method in pdo in php

Solutions on MaxInterview for bind method in pdo in php by the best coders in the world

showing results for - "bind method in pdo in php"
Manuel
03 Jan 2017
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();
Paul
09 Jan 2020
1$sql = "SELECT * FROM myTable WHERE id = ?";
2$stmt = $conn->prepare($sql);
3$stmt->execute([$id]);
Kelia
11 Jul 2017
1$sql = "SELECT * FROM myTable WHERE id = :id";
2$stmt = $conn->prepare($sql);
3$stmt->execute([":id"=>$id]);