Answers for "bind method in pdo in php"

PHP
1

bind method in pdo in php

If we had a value:

$sql = "SELECT * FROM myTable WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bindValue(1,1);
$stmt->execute();

If we had two values: 

$sql = "SELECT * FROM myTable WHERE id = ? and name = ?";
$stmt = $conn->prepare($sql);
$stmt->bindValue(1,1);
$stmt->bindValue(2,"alireza");
$stmt->execute();
Posted by: Guest on February-23-2021
4

bind in pdo

$sql = "SELECT * FROM myTable WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->execute([$id]);
Posted by: Guest on February-23-2021
4

bind in pdo

$sql = "SELECT * FROM myTable WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->execute([":id"=>$id]);
Posted by: Guest on February-23-2021

Browse Popular Code Answers by Language