Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

pdo php check if row exist

$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';
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pdo #php #check #row #exist
ADD COMMENT
Topic
Name
3+8 =