• 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 use PHPCBF to fix one issue at a time?

How to fix bootstrap multiselect search data using ajax

Laravel SQL query midnight time not showing

Php - Sum up the numbers in an array one by one

Changing font color in javascript

Doctrine 2 mapping referencing unique key

Laravel Database Strict Mode

Handle error for duplicate entries - PHP/MySQL

Apply filter array/return terms

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

args[max_input] woocommerce if statement confused

Doctrine 2 mapping referencing unique key

PHP code for generating decent-looking coupon codes (mix of letters and numbers)

Laravel Blade checkbox not checked

java URL working on browser but not in client program

About Contact Privacy policy Terms and conditions