• 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

Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

possible options to create pdf file using html elements to generate invoice in php and codeigniter

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

Get number of working days between two dates in PHP [duplicate]

How to to send mail using gmail in Laravel?

SQL AVG() to 2 decimals

how can I set a session variable in Drupal 8 and get it in a php script?

Edit XML in HTML form and submit to self

How to get monthly wise data in laravel

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

Google API Heatmap Layer exception, why?

ORA-12546: TNS:permission denied error connection to remote oracle server

Target Individual Form Instance/Counter Inside A PHP While Loop

How to extract price from given url using Xpath?

About Contact Privacy policy Terms and conditions