• 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

Laravel get user data with profile

PHP my timezone is no setting up in PHP.ini File in xampp

Laravel Excel::store file empty after stored

Check for PDO Results, If None Display Message, If Yes then Loop Through

Woocommerce redirect after add-to-cart error

Redis Command To Sort Keys

wordpress function breaks wp-admin

Invalid value in field "itemtype" in Google Search Console

Nginx RTMP not recording

Only on Firefox "Loading failed for the <script> with source"

Laravel PackageManifest.php: Undefined index: name

Querying only one row from a one to many relationship laravel

Handle error for duplicate entries - PHP/MySQL

Doctrine 2 mapping referencing unique key

Laravel phpunit test failing authorization

About Contact Privacy policy Terms and conditions