• 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

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

Laravel UUID generation

phpunit - mockbuilder - set mock object internal property

PHP: How to solve ob_start() in combination imagepng() issue?

How To Access A Column In M-M Relationship Table In Laravel

Composer Curl error 60: SSL certificate problem: unable to get local issuer certificate

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

Dynamic dropdown Ajax PHP request

How to create a individual template for page or post in custom plugin?

Image upload not working through ajax Laravel

How to identify whether webp image is static or animated?

Laravel query builder binding parameters more than once

Google Calendar API batch request PHP

Wordpress add responsive srcset header image to theme

Custom post type single page not working

About Contact Privacy policy Terms and conditions