• 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

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

How can I create a Download Page with post php method?

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

Search for array row with specific column value and return another value from qualifying row

correct PHP headers for pdf file download

How to test a php login connected to a mysql db through xampp?

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

file_put_content...fail to open stream:Permission denied in Laravel 5

How can I convert from a{a{} b{}} to a[a[],b[]] using php preg_match?

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

how to get value from array in laravel

How to get variable from JavaScript to PHP [duplicate]

Star rating with half star support

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

About Contact Privacy policy Terms and conditions