Skip to content

Commit

Permalink
Add try catch for tableExists function
Browse files Browse the repository at this point in the history
  • Loading branch information
spvickers committed Oct 17, 2022
1 parent ae84594 commit 9ef831a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ function tableExists($db, $name)
{
$sql = "select 1 from {$name}";
$query = $db->prepare($sql);
return $query->execute() !== false;
try {
$ok = $query->execute() !== false;
} catch (PDOException $e) {
$ok = false;
}

return $ok;
}

###
Expand Down

0 comments on commit 9ef831a

Please sign in to comment.