• 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

Laravel after login Two factor not working

selected value from the listbox in php

Remove product downloads section in woocommerce email notifications

Post Form Data To phpmyadmin Database

Autoloading classes in PHPUnit using Composer and autoload.php

wp_remote_get() not passing authentication

Laravel PackageManifest.php: Undefined index: name

Return multiple values from a function using mysqli_fetch_assoc [closed]

AJAX call fails with SyntaxError: Unexpected end of JSON input

Adding Multiple Custom Post Types in Wordpress

IlluminateDatabaseQueryException could not find driver [duplicate]

find in set in laravel ? example

Wordpress 'post_type_link' hides permalink

How can I get user id from session in javascript?

Parsing JSON File to array in PHP

About Contact Privacy policy Terms and conditions