• 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

Add New Parameter to Existing URL using htaccess

Getting values for an enum?

Installing Composer - Internal Error

PHPUnit (Phar) Fatal Error Only When Test Fails

Assign output of PHP function to a variable

how to make my own auto increment in php?

The "client_reference_id" argument is not passed

Creating command to backup MySql database in Laravel

add uri parameter to Route name in laravel

I want to use codeigniter foreign character library in my custom PHP project how i can use it?

How to keep value of selected value after form submission?

Extract house numbers from address string

Must be of the type array, null given,

Laravel Jetsream Profile page not loading on fresh install

Php - Sum up the numbers in an array one by one

About Contact Privacy policy Terms and conditions