📜  pdo php 检查行是否存在 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:30.490000             🧑  作者: Mango

代码示例2
$sql = 'SELECT 1 from table WHERE id = ? LIMIT 1';
//$sql = 'SELECT COUNT(*) from table WHERE param = ?'; // for checking >1 records
$stmt = $conn->prepare($sql);
$stmt->bindParam(1, $_GET['id'], PDO::PARAM_INT);
$stmt->execute();

if($stmt->fetchColumn()) echo 'found';