• 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 Create WooCommerce Subscription Product via. REST API?

Parameter is not sent to Laravel route in Ajax

How to write PHP in XSLT

WAMP Virtual Host not working

Wordpress 'post_type_link' hides permalink

Mysqli multi query error

how to make my own auto increment in php?

Adding multiple items to WooCommerce cart at once

Add restriction to WooCommerce coupons by allowed user ID

HTML and PHP in one file

Facebook PHP SDK - will not logout properly

"There is no active transaction" when refreshing database in Laravel 8.0 test

Problems getting instance of UploadedFile in Yii2

Store / Website Column in Magento 2 Admin Grid - Custom Module

Object of class stdClass could not be converted to string error

About Contact Privacy policy Terms and conditions