• 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 fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

How to test a php login connected to a mysql db through xampp?

str_replace or preg_replace random number from string

insert multiple rows in a saveall in cakephp

Edit product hook WooCommerce

Debugging Stripe Webhook Event

How to create custom authentication in laravel 8?

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

SQL AVG() to 2 decimals

Error when uploading certain .png files "Interlace handling should be turned on when using png_read_image"

Use same method for inertia response and json response Laravel Jetstream

possible options to create pdf file using html elements to generate invoice in php and codeigniter

Laravel 5 controller sending JSON integer as string

How to programmatically find public properties of a class from inside one of it's methods

Live search query using JS and PHP for QA forum

About Contact Privacy policy Terms and conditions