• 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

phpMyAdmin Accepts NULL in the NOT NULL field

How to get values inside <![CDATA[values]] > using php DOM?

How to get Laravel's CSRF Token from Another Website?

Using Associative arrays

Access relation of pivot table in Laravel

Laravel get user data with profile

Printing more than one array using print_r or any other function in php

Mysqli Output to a table

Laravel: Why is my variable not being set while it's in the construct function of the controller?

Live search query using JS and PHP for QA forum

Android Volley getParams() method not getting called for JsonObjectRequest

PHP: How to raise number to (tiny) fractional exponent?

retrieve data from database using session

merging two arrays with specified index

How to pass data to all views in Laravel 5?

About Contact Privacy policy Terms and conditions