• 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

how to remove white space in select 2

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

Laravel Multi-language routes without prefix

Laravel database insert with combining array and string

How can I create a Download Page with post php method?

Remove country code from phone number?

How to get variable from JavaScript to PHP [duplicate]

Converting alphabet letter to alphabet position in PHP [duplicate]

Symfony there are no commands defined in the "make" namespace

Match csv filenames to table names and import

Creating command to backup MySql database in Laravel

Cut an arabic string

Combine multiple columns into an array as one of the key in a results set

phpMyAdmin Accepts NULL in the NOT NULL field

How to test a php login connected to a mysql db through xampp?

About Contact Privacy policy Terms and conditions