• 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

str_word_count() function doesn't display Arabic language properly

PHP Download MP3 files from directory on server

Converting alphabet letter to alphabet position in PHP [duplicate]

How to send upload image through email

Cannot connect to own websocket server when on secured domain

PHP contact form configuration [duplicate]

How to run a shell as root from php (apache)

Facebook PHP SDK - will not logout properly

(Cache::lock()) -> get() -- Under what conditions does it return false?

Why i get wrong output for html markdown?

MySQL order by field in Eloquent

Laravel Unknown Column 'updated_at'

How to set dynamic `home` and `siteurl` in WordPress?

Add and update products to session cart in Laravel

Use Python plotly chart in PHP

About Contact Privacy policy Terms and conditions