• 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

Correct way to use LIKE '%{$var}%' with prepared statements?

Google Gmail API - How to login programatically?

Why is this PHP array not the same?

Issue saving card for customer

Getting values for an enum?

Laravel Gates using model and returns "Using $this when not in object context" Line 28 of AzureUser model

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

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

Send POST data via raw JSON with Postman

Jquery DataTables: Data not displaying in table via Ajax

Symfony redirect if already loggedin from login page

I cannot create a auto generated date time in mysql workbench

Sum column values from multiple arrays

Select option menu read from database and use it's values

Transpose csv file data [duplicate]

About Contact Privacy policy Terms and conditions