• 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

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

Composer Script echo

Group data in a multidimensional array based on two columns

Navigation idle on content download

Creating live search with AJAX and CodeIgniter

Unable to run composer install

Mobile browsers are adding .html to filename on download

How to pass data to all views in Laravel 5?

Cache clear probem in Larave

Symfony - EasyAdmin - Add and remove functions are ignored from AssociationField

How to KeyBy where multiple items have the same key

Laravel Command Schedule Not Working Properly

Encrypt in php and decrypt in Dart(flutter)

Object of class stdClass could not be converted to string error

Add a custom text for a particular product on specific email notification in Woocommerce

About Contact Privacy policy Terms and conditions