• 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

php echo xml documents with header

How to read laravel_session cookies saved in cookie memory of browser in client side?

Symfony Error: "An exception has been thrown during the rendering of a template"

Load a .env file with PHP

Read users and passwords from a txt file

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

how to make my own auto increment in php?

I can't delete my image when it is liked because of the foreign key in mysql

PHP: PDO + CSV export not downloading (headers issue?)

laravel sanctum Route [login] not defined

How to get transaction details in notify_url page in paypal

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

PHP: Insert marker every 3 iterations

About Contact Privacy policy Terms and conditions