• 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 record for each array elements if missing in table

Insert multidimensional array to codeigniter cart

Detect emoticons in string

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

find in set in laravel ? example

Post Form Data To phpmyadmin Database

Inserting Country Selection into MySQL PHP [duplicate]

500 (Internal Server Error) with Laravel & Docker [duplicate]

Xdebug in Laravel is not working with VSCode

Merge column values from two arrays to form an indexed array of associative arrays

laravel sanctum Route [login] not defined

SilverStripe unable to populate multiple member Childs

Symfony run hint kernel.secret parameter not found

phpMyAdmin Accepts NULL in the NOT NULL field

About Contact Privacy policy Terms and conditions