• 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

PHP: Calling MySQL Stored Procedure with Both INPUT AND OUTPUT Parameters (NOT "INOUT")

Passing a boolean value from checkbox in Laravel form

WordPress - Dynamically add user ID to the end of a URL

Reorder attribute dropdown terms in Woocommerce single variable products

Creating Combinations of Elements

Laravel relationship belongsToMany with composite primary keys

Check If array is null or not in php

cakephp save drag and drop list order to database

Transpose csv file data [duplicate]

Filter WooCommerce related products by Polylang language

PHP web3 ERC20 token function call

PHP to search within txt file and echo the whole line

wordpress function breaks wp-admin

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

carbon generated datetime not stored correctly into the database

About Contact Privacy policy Terms and conditions