• 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 delete old images from public folder on update using Laravel

Mysqli Output to a table

PHP: Convert any string to UTF-8 without knowing the original character set, or at least try

How to validate Envato Purchase Code in PHP

how to make my own auto increment in php?

WooCommerce Additional Information - if empty, hide

Call authenticate manually in router middleware

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Substitute integers and dots with regex [duplicate]

Laravel websockets AWS EC2 - Connection failed

How to loop a tree array with unknown depth and get array blocks?

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

Pages are working fine on localhost but not running on the hosting server

Access relation of pivot table in Laravel

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

About Contact Privacy policy Terms and conditions