how to see if database exists with PDO [duplicate]
PHP Snippet 1:
$stmt = $pdo->query("SELECT COUNT(*) FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'DBName'");
return (bool) $stmt->fetchColumn();
PHP Snippet 2:
try {
$conn->exec($sql);
} catch (PDOException $th) {
echo "<br> sql error";
}