PHP PDO search for a value in two or more columns using one string

前端 未结 4 1139
清酒与你
清酒与你 2020-12-10 23:54

When I want to find a value from a row using PDO I use the following method:

//Search whether user exists
$sqlQueryEmailLogin = $dbh->prepare(\"SELECT ven         


        
4条回答
  •  遥遥无期
    2020-12-11 00:28

    Try the following

    $sql = "SELECT * FROM articles WHERE id = :id AND status = :status";
    $stmt = $conn->prepare($sql);
    $stmt->bindValue(':id', $id); 
    $stmt->bindValue(':status', $status); 
    $stmt->execute();
    

    See docs http://php.net/manual/en/pdostatement.bindvalue.php

提交回复
热议问题