• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

how to see if database exists with PDO [duplicate]

phpmysqlpdo


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";
        }

Related Snippets

generating a random code in php?

How to get the ID of the link in another page in php

Override default Auth routes in Laravel 7

Laravel 5.1 how to use {{ old('') }} helper on blade file for radio inputs

Filter array by skipping every nth element from the end

Adding the custom page with add_menu_page function on Wordpress

Explain how this array transposing and flattening function works

How to add a heading in between checkout fields of WooCommerce

Laravel insert dynamic input values with radio button

Unable to Edit config.inc.php

MOODLE: What does it mean to aggregate h5p assets?

PHP - Store information with NO database

PHP how to detect if running on arm64 cpu?

auth pages not getting css in laravel

Using PHP to connect to a remote MSSQL database

About Contact Privacy policy Terms and conditions