• 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 retrieve Active Directory group policy maximum password age using LDAP

echo language construct is discouraged. (PHP)

How to get multiple values with same key from an array PHP

Lexik JWT authentication problem "Invalid credentials"

Using Associative arrays

java URL working on browser but not in client program

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

PHPMyAdmin not working as intended at remote server. Error 500, $respond not found

PHP Fatal error: Class not found - PHPUnit

How to override htaccees file for cache control header

No definition found for function in vendor vscode

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Post Form Data To phpmyadmin Database

cakephp save drag and drop list order to database

Adding Multiple Custom Post Types in Wordpress

About Contact Privacy policy Terms and conditions