• 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

Backend cannot be reached after Typo3 login screen

PHP array slice from position + attempt to return fixed number of items

javascript html popup window

stay with the last 15 elements of an array [duplicate]

how to loop through json response data using ajax jquery?

What will the best solution for this multiple optional filter?

Combining a describing and one array with data

Yii Ajax Submit button

protect images from being copied

Magento 2 - Controller returning blank page

Having issue with matching rows in the database using PDO

Custom post type single page not working

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

api response laravel doesn't show

How to execute sql code based on fetch array

About Contact Privacy policy Terms and conditions