• 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 Sorting - getting 10, 11, 12 ... 1, 20, 2 rather than 1, 10, 11, 12 ... 2, 20

Laravel passport auth token not working after moving to different server

Best way to scrolldown onpageload

How to set a domain name with php artisan serve

PHP and WebView - Cookie doesn't are the same

Assets not referencing to public folder (Laravel)

Dropzone: Submit both form data and dropzone at once

How to load Codeigniter 4 lang file into an array variable

PHPExcel export HTML table to xlsx

How to add a custom field to all Woocommerce attribute terms using add_action

How do I remove this delivery notification from here?

printing all running session variable in laravel 5.1

PHP mail sending empty mails

phpunit - testing is painfully slow

Upload a file Using PHP and JavaScript

About Contact Privacy policy Terms and conditions