• 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

Star rating with half star support

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

How to access a var with "-" in PHP [duplicate]

Upgrade PHP on AWS Linux

browsersync doesn't work with XAMPP

PHP: Telegram Bot: Insert line break to text message

How to get Laravel's CSRF Token from Another Website?

Convert date and time to Jalali in Laravel

How to display MySQL table using php and edit it in a web browser

MySQL upgrade causing unexpected results on simple WHERE clauses

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

WordPress Subquery returns more than 1 row on SELECT

GRPC installed successfully on ubuntu but php is looking for it in another folder

Laravel Passport - Not able to get token string in response?

About Contact Privacy policy Terms and conditions