如果SELECT查询返回false,我希望我的代码执行, 这是我的以下代码:
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->beginTransaction();
if(!$dbh->query($stmt)){
$query->execute();
if($stmt->execute()){
while($row = $stmt->fetch()){
for ($i = 0;
$i < count($defect[0]);
$i++){
$stmtDefect->bindParam(':purgeID', $row['purgeID']);
$stmtDefect->bindParam(':defectID', $defect[0][$i]);
$stmtDefect->bindParam(':action', $action[0][$i]);
$stmtDefect->execute();
}//end for
}//end while
}//end if
$dbh->commit();
echo "Data Successfully added";
} else {
echo "Sequence: " . $sequence . " already checked";
}
我知道如果找不到行,query()将返回false ....但是这段代码将始终执行