• 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

Only on Firefox "Loading failed for the <script> with source"

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

PHP mail function is sending blank message body

Laravel Get Days In Month From Month Number?

Laravel relationship belongsToMany with composite primary keys

Update Order custom Field value with WooCommerce REST API

Limit of log line written to Apache Errorlog from mod php error_log

PHP-Sort array based on another array?

Timber: Single post pagination does not work (wp_link_pages)

printing all running session variable in laravel 5.1

PHP, how to convert Int value to Week days

Nginx RTMP not recording

PHP my timezone is no setting up in PHP.ini File in xampp

api response laravel doesn't show

PDOException SQLSTATE[HY000] [2002] No such file or directory

About Contact Privacy policy Terms and conditions