• 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

With doctrine ODM, can I embed many subdocuments in a main document?

how to remove %20 in the url in php

How to get multiple values with same key from an array PHP

Get orders by date and status woocommerce

Laravel csrf token mismatch for ajax POST Request

How to pass security cloudflare server with php curl

PHP mail sending empty mails

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

Get lat/lon from google maps url ftid (hex)

Assets not referencing to public folder (Laravel)

Group data in a multidimensional array based on two columns

Mysqli Output to a table

PHP my timezone is no setting up in PHP.ini File in xampp

PHP block shortcut in Visual Studio Code

PHP: Print caught exception like Xdebug

About Contact Privacy policy Terms and conditions